Method: Roby::Log::EventStream#read

Defined in:
lib/roby/log/event_stream.rb

#readObject

Reads a sample of data and returns it. It will be fed to decoders’ #decode method.

In this stream, this is the chunk of the marshalled file which corresponds to a cycle



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/roby/log/event_stream.rb', line 102

def read
    if reinit?
 reinit!
    end

    start_pos = index_data[current_cycle][:pos]
    end_pos   = if index_data.size > current_cycle + 1
        index_data[current_cycle + 1][:pos]
  else
        logfile.stat.size
  end

    logfile.seek(start_pos)
    logfile.read(end_pos - start_pos)

ensure
    @current_cycle += 1
end