Class: RRD::DataSource

Inherits:
Object
  • Object
show all
Defined in:
lib/rrd/data_source.rb

Constant Summary collapse

PARAMS =
[
  :min_heartbeat, :min_value, :max_value
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, options = {}) ⇒ DataSource

Returns a new instance of DataSource.



9
10
11
12
# File 'lib/rrd/data_source.rb', line 9

def initialize(name, type, options = {})
  @name, @type = name, type
  @options = options
end

Instance Attribute Details

#last_dsObject

Returns the value of attribute last_ds.



7
8
9
# File 'lib/rrd/data_source.rb', line 7

def last_ds
  @last_ds
end

#last_valueObject

Returns the value of attribute last_value.



7
8
9
# File 'lib/rrd/data_source.rb', line 7

def last_value
  @last_value
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/rrd/data_source.rb', line 7

def name
  @name
end

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/rrd/data_source.rb', line 7

def options
  @options
end

#typeObject

Returns the value of attribute type.



7
8
9
# File 'lib/rrd/data_source.rb', line 7

def type
  @type
end

#unknown_secondsObject

Returns the value of attribute unknown_seconds.



7
8
9
# File 'lib/rrd/data_source.rb', line 7

def unknown_seconds
  @unknown_seconds
end

Class Method Details

.parse(reader) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rrd/data_source.rb', line 14

def self.parse(reader)
  name = reader.read_string(20, "A*")
  type = reader.read_string(20, "A*")
  params = Hash[PARAMS.zip(reader.read_uniparams(10))]

  options = {
    min_heartbeat: params[:min_heartbeat].to_i,
    min_value: params[:min_value].to_f,
    max_value: params[:max_value].to_f
  }
 
  DataSource.new(name, type, options)
end

Instance Method Details

#cdpObject



28
29
30
# File 'lib/rrd/data_source.rb', line 28

def cdp
  @cdp ||= []
end

#inspectObject



32
33
34
# File 'lib/rrd/data_source.rb', line 32

def inspect
  "<RRD::DataSource name='#{name}' type='#{type}' options='#{options}'>"
end