Class: OpenNebula::Records
- Inherits:
-
RecordsSource
- Object
- RecordsSource
- OpenNebula::Records
- Defined in:
- service/records/records.rb
Overview
(History)Records source class for fullfilling Timeline
Instance Attribute Summary
Attributes inherited from RecordsSource
Instance Method Summary collapse
-
#init_state(stime) ⇒ Object
Calculates nitial state for timeline(such as VM was turn on before stime, state would be 'on').
-
#initialize(id) ⇒ Records
constructor
inits RecordsSource class with Record class as base.
Methods inherited from RecordsSource
check_source, #find, #key, #records, tl_filter
Constructor Details
Instance Method Details
#init_state(stime) ⇒ Object
Calculates nitial state for timeline(such as VM was turn on before stime, state would be 'on')
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'service/records/records.rb', line 97 def init_state stime prev = @records.where { time < stime }.order(Sequel.desc :time).limit(1).to_a.last if prev.nil? then curr = @records.where { time >= stime }.limit(1).to_a.first return {} if curr.nil? { state: curr.state } else { state: prev.state } end end |