Class: Issuesrc::FSFile
- Inherits:
-
Object
- Object
- Issuesrc::FSFile
- Defined in:
- lib/issuesrc/file.rb
Overview
A file from the filesystem.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(path) ⇒ FSFile
constructor
A new instance of FSFile.
- #replace_at(pos, old_content_length, new_content) ⇒ Object
Constructor Details
#initialize(path) ⇒ FSFile
Returns a new instance of FSFile.
27 28 29 30 |
# File 'lib/issuesrc/file.rb', line 27 def initialize(path) @path = path @type = File.extname(path).slice(1..-1) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
25 26 27 |
# File 'lib/issuesrc/file.rb', line 25 def path @path end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
24 25 26 |
# File 'lib/issuesrc/file.rb', line 24 def type @type end |
Instance Method Details
#body ⇒ Object
32 33 34 |
# File 'lib/issuesrc/file.rb', line 32 def body File.open(@path, 'r') end |
#replace_at(pos, old_content_length, new_content) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/issuesrc/file.rb', line 36 def replace_at(pos, old_content_length, new_content) fbody = body.read fbody = replace_in_string(fbody, pos, old_content_length, new_content) f = body_for_writing() f.write(fbody) f.close() end |