Module: IndifferentReader
Defined Under Namespace
Modules: IOString Classes: DataError
Instance Method Summary collapse
Instance Method Details
#read_from(io_or_string, size) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/indifferent_reader.rb', line 19 def read_from io_or_string, size if io_or_string.kind_of? String io_or_string.extend IOString end if io_or_string.respond_to? :read result = io_or_string.read(size) elsif io_or_string.nil? raise DataError.new("Perhaps DATA has ended? check your FHP.", io_or_string) else raise "Unknown source: #{io_or_string.inspect}" end return result end |