class PRRD::Graph::Line
Public Class Methods
new(values = nil)
click to toggle source
Constructor
Calls superclass method
PRRD::Entity::new
# File lib/prrd/graph/line.rb, line 11 def initialize(values = nil) @keys = [ :value, :width, :color, :legend, :stack ] super values end
Public Instance Methods
to_s()
click to toggle source
Transform to a LINE formatted string
# File lib/prrd/graph/line.rb, line 24 def to_s fail 'Empty line object' if @data.empty? @data[:width] ||= 1 validate_presence :value chunks = [] @keys.each do |k| next unless @data.key?(k) case k when :value chunks << "LINE%s:%s%s" % [@data[:width], @data[k], @data[:color]] when :width, :color # nope when :legend chunks << "\"%s\"" % @data[k] when :stack chunks << "STACK" else chunks << @data[k] end end chunks.join ':' end