Class: PRRD::Graph::Area
Overview
PRRD Graph Area class
Instance Attribute Summary
Attributes inherited from Entity
Instance Method Summary collapse
-
#initialize(values = nil) ⇒ Area
constructor
Constructor.
-
#to_s ⇒ Object
Transform to a AREA formatted string.
Methods inherited from Entity
#method_missing, #validate_presence
Constructor Details
#initialize(values = nil) ⇒ Area
Constructor
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/prrd/graph/area.rb', line 11 def initialize(values = nil) @keys = [ :value, :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 AREA formatted string
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/prrd/graph/area.rb', line 23 def to_s fail 'Empty area object' if @data.empty? validate_presence :value chunks = [] @keys.each do |k| next unless @data.key?(k) case k when :value chunks << "AREA:%s%s" % [@data[k], @data[:color]] when :legend chunks << "\"%s\"" % @data[k] when :stack chunks << "STACK" when :color # nope else chunks << @data[k] end end chunks.join ':' end |