Class: TrafficRecord

Inherits:
Object
  • Object
show all
Defined in:
service/records/traffic_records.rb

Overview

Traffic Record Model class

Instance Method Summary collapse

Instance Method Details

#conv_keysObject

Keys which do need to be converted from String to Integer



35
36
37
# File 'service/records/traffic_records.rb', line 35

def conv_keys
  [:rx, :tx, :rx_last, :tx_last]
end

#mod(st) ⇒ Object

Replaces state rx/tx values with current ones



30
31
32
# File 'service/records/traffic_records.rb', line 30

def mod st
  st.merge! rx: rx.to_i, tx: tx.to_i
end

#sortableObject

TrafficRecord is sortable itself, so just returns itself



19
20
21
# File 'service/records/traffic_records.rb', line 19

def sortable
  self
end

#sorterObject Also known as: ts

Since Traffic Record is useful only as it has etime sorter is 'end time'



24
25
26
# File 'service/records/traffic_records.rb', line 24

def sorter
  etime
end

#to_iObject

Convert all values which do need to be converted to Integer



40
41
42
43
44
45
# File 'service/records/traffic_records.rb', line 40

def to_i
  for key in conv_keys do
    @values[key] = @values[key].to_i
  end
  self
end

#to_json(*args) ⇒ Object

Needed for serialization



48
49
50
# File 'service/records/traffic_records.rb', line 48

def to_json *args
  @values.without(:key).to_json(*args)
end