Class: RecordsSource

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

Overview

Source of History records class

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cls, id) ⇒ RecordsSource

Returns a new instance of RecordsSource.

Parameters:

  • id (Integer)
    • VM ID



11
12
13
14
# File 'service/records.rb', line 11

def initialize cls, id
  @id = id
  @records = cls.where(Hash[key, @id])
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'service/records.rb', line 3

def id
  @id
end

Class Method Details

.check_source(_vm) ⇒ Object

Check if source should be used with given VM



37
38
39
# File 'service/records.rb', line 37

def self.check_source _vm
  true
end

.tl_filter(records) ⇒ Object

Filter records needed for Showback Timeline



32
33
34
# File 'service/records.rb', line 32

def self.tl_filter records
  records
end

Instance Method Details

#find(stime, etime) ⇒ Object

Find records for given time period



22
23
24
# File 'service/records.rb', line 22

def find stime, etime
  @records.where(time: stime..etime)
end

#init_state(_stime) ⇒ Object

Initial timeline state



27
28
29
# File 'service/records.rb', line 27

def init_state _stime
  {}
end

#keyObject

VMID field key



6
7
8
# File 'service/records.rb', line 6

def key
  :id
end

#recordsObject

Return all records for this VM(@id)



17
18
19
# File 'service/records.rb', line 17

def records
  @records.all
end