Class: CPEE::Logging::HeaderAndFile
- Inherits:
-
Object
- Object
- CPEE::Logging::HeaderAndFile
- Defined in:
- lib/cpee-logging-xes-yaml/implementation.rb
Overview
{{{
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(header, io) ⇒ HeaderAndFile
constructor
A new instance of HeaderAndFile.
- #read(length = nil, outbuf = nil) ⇒ Object
- #rewind ⇒ Object
Constructor Details
#initialize(header, io) ⇒ HeaderAndFile
Returns a new instance of HeaderAndFile.
68 69 70 71 72 |
# File 'lib/cpee-logging-xes-yaml/implementation.rb', line 68 def initialize(header, io) @header = header @io = io @position = 0 end |
Instance Method Details
#close ⇒ Object
95 96 97 98 |
# File 'lib/cpee-logging-xes-yaml/implementation.rb', line 95 def close @io&.close @io = nil end |
#read(length = nil, outbuf = nil) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/cpee-logging-xes-yaml/implementation.rb', line 74 def read(length = nil, outbuf = nil) if @position < @header.bytesize data = read_header(length) if length && data.bytesize < length remaining_length = length - data.bytesize file_data = @io.read data << file_data if file_data end else data = @io.read(length) end return data.nil? || data.empty? && length ? nil : append_to_outbuf(data, outbuf) end |
#rewind ⇒ Object
90 91 92 93 |
# File 'lib/cpee-logging-xes-yaml/implementation.rb', line 90 def rewind @io&.rewind @position = 0 # returning position is the way rewind does it end |