Class: RRD::Xport
- Inherits:
-
Object
- Object
- RRD::Xport
- Defined in:
- lib/rrd/xport.rb
Constant Summary collapse
- DEF_OPTIONS =
[:from]
Instance Attribute Summary collapse
-
#definitions ⇒ Object
Returns the value of attribute definitions.
-
#output ⇒ Object
Returns the value of attribute output.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#printables ⇒ Object
Returns the value of attribute printables.
Instance Method Summary collapse
- #for_rrd_data(data_name, options) ⇒ Object
-
#initialize(parameters = {}) ⇒ Xport
constructor
A new instance of Xport.
- #save ⇒ Object
- #using_calculated_data(data_name, options) ⇒ Object
- #xport(data_name, options) ⇒ Object
Constructor Details
#initialize(parameters = {}) ⇒ Xport
Returns a new instance of Xport.
9 10 11 12 13 14 15 16 |
# File 'lib/rrd/xport.rb', line 9 def initialize(parameters = {}) @parameters = {:start => Time.now - 1.day, :end => Time.now}.merge parameters @parameters[:start] = @parameters[:start].to_i @parameters[:end] = @parameters[:end].to_i @definitions = [] @printables = [] end |
Instance Attribute Details
#definitions ⇒ Object
Returns the value of attribute definitions.
5 6 7 |
# File 'lib/rrd/xport.rb', line 5 def definitions @definitions end |
#output ⇒ Object
Returns the value of attribute output.
5 6 7 |
# File 'lib/rrd/xport.rb', line 5 def output @output end |
#parameters ⇒ Object
Returns the value of attribute parameters.
5 6 7 |
# File 'lib/rrd/xport.rb', line 5 def parameters @parameters end |
#printables ⇒ Object
Returns the value of attribute printables.
5 6 7 |
# File 'lib/rrd/xport.rb', line 5 def printables @printables end |
Instance Method Details
#for_rrd_data(data_name, options) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/rrd/xport.rb', line 18 def for_rrd_data(data_name, ) dataset = .reject {|name, value| DEF_OPTIONS.include?(name.to_sym)} definition = "DEF:#{data_name}=#{[:from]}:#{dataset.keys.first}:#{dataset.values.first.to_s.upcase}" definitions << definition definition end |
#save ⇒ Object
37 38 39 |
# File 'lib/rrd/xport.rb', line 37 def save Wrapper.xport(*generate_args) end |
#using_calculated_data(data_name, options) ⇒ Object
25 26 27 28 29 |
# File 'lib/rrd/xport.rb', line 25 def using_calculated_data(data_name, ) definition = "CDEF:#{data_name}=#{[:calc]}" definitions << definition definition end |
#xport(data_name, options) ⇒ Object
31 32 33 34 35 |
# File 'lib/rrd/xport.rb', line 31 def xport(data_name, ) printable = "XPORT:#{data_name}:#{[:label].gsub(/:/, '\\:')}" printables << printable [printable] end |