Class: TrafficRecord
- Inherits:
-
Object
- Object
- TrafficRecord
- Defined in:
- service/records/traffic_records.rb
Overview
Traffic Record Model class
Instance Method Summary collapse
-
#conv_keys ⇒ Object
Keys which do need to be converted from String to Integer.
-
#mod(st) ⇒ Object
Replaces state rx/tx values with current ones.
-
#sortable ⇒ Object
TrafficRecord is sortable itself, so just returns itself.
-
#sorter ⇒ Object
(also: #ts)
Since Traffic Record is useful only as it has etime sorter is 'end time'.
-
#to_i ⇒ Object
Convert all values which do need to be converted to Integer.
-
#to_json(*args) ⇒ Object
Needed for serialization.
Instance Method Details
#conv_keys ⇒ Object
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 |
#sortable ⇒ Object
TrafficRecord is sortable itself, so just returns itself
19 20 21 |
# File 'service/records/traffic_records.rb', line 19 def sortable self end |
#sorter ⇒ Object 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_i ⇒ Object
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 |