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