class PRRD::Graph::Definition

PRRD Graph Definition class

Public Class Methods

new(values = nil) click to toggle source

Constructor

Calls superclass method PRRD::Entity::new
# File lib/prrd/graph/definition.rb, line 11
def initialize(values = nil)
  @keys = [
    :vname,
    :rrdfile,
    :ds_name,
    :cf,
    :step,
    :start,
    :end
  ]

  super values
end

Public Instance Methods

to_s() click to toggle source

Transform to a DEF formatted string

# File lib/prrd/graph/definition.rb, line 26
def to_s
  fail 'Empty definition object' if @data.empty?

  chunks = []

  @keys.each do |k|
    next unless @data.key?(k)
    case k
    when :vname
      chunks << "DEF:%s=%s" % [@data[k], @data[:rrdfile]]
    when :rrdfile
      # nope
    else
      chunks << @data[k]
    end
  end

  chunks.join ':'
end