Class: Miasma::Models::Storage::File::Streamable
- Inherits:
-
Object
- Object
- Miasma::Models::Storage::File::Streamable
- Defined in:
- lib/miasma/models/storage/file.rb
Overview
Simple wrapper to keep consistent reading behavior
Instance Attribute Summary (collapse)
-
- (Object) io
readonly
IO-ish thing.
Instance Method Summary (collapse)
-
- (Streamable) initialize(io_item)
constructor
A new instance of Streamable.
-
- (Object) method_missing(method_name, *args, &block)
Proxy missing methods to io.
-
- (String) readpartial(length = nil)
Customized readpartial to automatically hand EOF.
Constructor Details
- (Streamable) initialize(io_item)
Returns a new instance of Streamable
17 18 19 20 21 22 |
# File 'lib/miasma/models/storage/file.rb', line 17 def initialize(io_item) unless(io_item.respond_to?(:readpartial)) raise TypeError.new 'Instance must respond to `#readpartial`' end @io = io_item end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(method_name, *args, &block)
Proxy missing methods to io
25 26 27 28 29 30 31 |
# File 'lib/miasma/models/storage/file.rb', line 25 def method_missing(method_name, *args, &block) if(io.respond_to?(method_name)) io.send(method_name, *args, &block) else raise end end |
Instance Attribute Details
- (Object) io (readonly)
Returns IO-ish thing
15 16 17 |
# File 'lib/miasma/models/storage/file.rb', line 15 def io @io end |
Instance Method Details
- (String) readpartial(length = nil)
Customized readpartial to automatically hand EOF
37 38 39 40 41 42 43 |
# File 'lib/miasma/models/storage/file.rb', line 37 def readpartial(length=nil) begin io.readpartial(length) rescue EOFError nil end end |