Class: Issuesrc::FSFile
- Inherits:
-
Object
- Object
- Issuesrc::FSFile
- Defined in:
- lib/issuesrc/file.rb
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.
6 7 8 9 |
# File 'lib/issuesrc/file.rb', line 6 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.
4 5 6 |
# File 'lib/issuesrc/file.rb', line 4 def path @path end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/issuesrc/file.rb', line 3 def type @type end |
Instance Method Details
#body ⇒ Object
11 12 13 |
# File 'lib/issuesrc/file.rb', line 11 def body File.open(@path, 'r') end |
#replace_at(pos, old_content_length, new_content) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/issuesrc/file.rb', line 15 def replace_at(pos, old_content_length, new_content) fbody = body.read fbody = replace_in_string(fbody, pos, old_content_length, new_content) f = File.open(@path, 'wb') f.write(fbody) f.close() end |