Class: ChupaText::VirtualContent
- Inherits:
-
Object
- Object
- ChupaText::VirtualContent
- Defined in:
- lib/chupa-text/virtual-content.rb
Constant Summary collapse
- KILO_BYTE =
1024- BUFFER_SIZE =
64 * KILO_BYTE
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(input, original_path = nil) ⇒ VirtualContent
constructor
A new instance of VirtualContent.
- #open(&block) ⇒ Object
- #path ⇒ Object
Constructor Details
#initialize(input, original_path = nil) ⇒ VirtualContent
Returns a new instance of VirtualContent.
26 27 28 29 30 31 32 33 |
# File 'lib/chupa-text/virtual-content.rb', line 26 def initialize(input, original_path=nil) @file = nil @base_name = compute_base_name(original_path) @body = nil setup_file do |file| @size = IO.copy_stream(input, file) end end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
25 26 27 |
# File 'lib/chupa-text/virtual-content.rb', line 25 def size @size end |
Instance Method Details
#body ⇒ Object
39 40 41 |
# File 'lib/chupa-text/virtual-content.rb', line 39 def body @body ||= open {|file| file.read} end |
#open(&block) ⇒ Object
35 36 37 |
# File 'lib/chupa-text/virtual-content.rb', line 35 def open(&block) File.open(path, "rb", &block) end |
#path ⇒ Object
43 44 45 |
# File 'lib/chupa-text/virtual-content.rb', line 43 def path @path end |