Class: PRRD::Graph::Line
Overview
PRRD Graph Line class
Instance Attribute Summary
Attributes inherited from Entity
Instance Method Summary collapse
-
#initialize(values = nil) ⇒ Line
constructor
Constructor.
-
#to_s ⇒ Object
Transform to a LINE formatted string.
Methods inherited from Entity
#method_missing, #validate_presence
Constructor Details
#initialize(values = nil) ⇒ Line
Constructor
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/prrd/graph/line.rb', line 11 def initialize(values = nil) @keys = [ :value, :width, :color, :legend, :stack ] super values end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class PRRD::Entity
Instance Method Details
#to_s ⇒ Object
Transform to a LINE formatted string
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# 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 |