Class: PRRD::Graph::Hrule
Overview
PRRD Graph Hrule class
Instance Attribute Summary
Attributes inherited from Entity
Instance Method Summary collapse
-
#initialize(values = nil) ⇒ Hrule
constructor
Constructor.
-
#to_s ⇒ Object
Transform to a HRULE formatted string.
Methods inherited from Entity
#method_missing, #validate_presence
Constructor Details
#initialize(values = nil) ⇒ Hrule
Constructor
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/prrd/graph/hrule.rb', line 13 def initialize(values = nil) @keys = [ :value, :color, :legend, :dashes, :dashes_offset ] 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 HRULE formatted string
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/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 |