Class: Issuesrc::FSFile

Inherits:
Object
  • Object
show all
Defined in:
lib/issuesrc/file.rb

Direct Known Subclasses

GitFile

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/issuesrc/file.rb', line 4

def path
  @path
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/issuesrc/file.rb', line 3

def type
  @type
end

Instance Method Details

#bodyObject



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