Class: RRDQuery
- Inherits:
-
Object
- Object
- RRDQuery
- Defined in:
- lib/rrd_query.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
- #_rrd ⇒ Object
-
#initialize(filename) ⇒ RRDQuery
constructor
A new instance of RRDQuery.
- #latest_value(datasource) ⇒ Object
Constructor Details
#initialize(filename) ⇒ RRDQuery
Returns a new instance of RRDQuery.
6 7 8 |
# File 'lib/rrd_query.rb', line 6 def initialize(filename) @filename = filename end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
4 5 6 |
# File 'lib/rrd_query.rb', line 4 def filename @filename end |
Instance Method Details
#_rrd ⇒ Object
14 15 16 17 |
# File 'lib/rrd_query.rb', line 14 def _rrd raise("Unable to open RRD, because it doesn't exist: #{@filename}") unless File.exist?(@filename) @rrd ||= RRD::Base.new(@filename) end |
#latest_value(datasource) ⇒ Object
10 11 12 |
# File 'lib/rrd_query.rb', line 10 def latest_value(datasource) _rrd.info["ds[#{datasource}].last_ds"].to_f end |