Class: ChupaText::FileContent

Inherits:
Object
  • Object
show all
Defined in:
lib/chupa-text/file-content.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileContent

Returns a new instance of FileContent.



22
23
24
25
# File 'lib/chupa-text/file-content.rb', line 22

def initialize(path)
  @path = path
  @size = File.size(@path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



20
21
22
# File 'lib/chupa-text/file-content.rb', line 20

def path
  @path
end

#sizeObject (readonly)

Returns the value of attribute size.



19
20
21
# File 'lib/chupa-text/file-content.rb', line 19

def size
  @size
end

Instance Method Details

#bodyObject



31
32
33
# File 'lib/chupa-text/file-content.rb', line 31

def body
  @body ||= open {|file| file.read}
end

#open(&block) ⇒ Object



27
28
29
# File 'lib/chupa-text/file-content.rb', line 27

def open(&block)
  File.open(@path, "rb", &block)
end