class TRecs::JsonReader
Attributes
frames[R]
player[RW]
source[R]
timestamps[R]
Public Class Methods
new(options={})
click to toggle source
# File lib/trecs/readers/json_reader.rb, line 11 def initialize(options={}) @source = options.fetch(:source) { trecs_backend = options.fetch(:trecs_backend) TgzSource.new(trecs_backend: trecs_backend) } @frames = get_frames @timestamps = @frames.keys end
Public Instance Methods
frame_at(time)
click to toggle source
# File lib/trecs/readers/json_reader.rb, line 40 def frame_at(time) @frames[time] end
get_frames()
click to toggle source
# File lib/trecs/readers/json_reader.rb, line 24 def get_frames frames = {} source.read do json_string = source.read_entry("frames.json") || "{}" parsed_json = JSON.parse(json_string, symbolize_names: true) parsed_json.each do |time, value| frames[Integer(time.to_s)] = Frame(value) end end frames end
manifest()
click to toggle source
# File lib/trecs/readers/json_reader.rb, line 20 def manifest source.manifest end
setup()
click to toggle source
# File lib/trecs/readers/json_reader.rb, line 36 def setup true end
to_s()
click to toggle source
# File lib/trecs/readers/json_reader.rb, line 44 def to_s "<#{self.class}>" end
Also aliased as: inspect