Class: SmartChart::Encoder::Base
- Inherits:
-
Object
- Object
- SmartChart::Encoder::Base
- Defined in:
- lib/smart_chart/encoder.rb
Overview
The Base encoder defines a public interface for all Encoders. To create an actual Encoder, your subclass should implement only these private methods:
token # the single character encoding name
digits # the "alphabet" of the encoding (array)
missing # digit used for missing data
delimiter # between data points
separator # between data series
Instance Attribute Summary collapse
-
#data_sets ⇒ Object
Returns the value of attribute data_sets.
-
#max ⇒ Object
Returns the value of attribute max.
-
#min ⇒ Object
Returns the value of attribute min.
Instance Method Summary collapse
-
#initialize(data_sets, min = nil, max = nil) ⇒ Base
constructor
A new instance of Base.
-
#to_s ⇒ Object
The data, encoded as a string (eg: “s:e5Gf4”).
Constructor Details
#initialize(data_sets, min = nil, max = nil) ⇒ Base
Returns a new instance of Base.
26 27 28 29 30 |
# File 'lib/smart_chart/encoder.rb', line 26 def initialize(data_sets, min = nil, max = nil) self.data_sets = data_sets self.min = min || data_sets.flatten.compact.min self.max = max || data_sets.flatten.compact.max end |
Instance Attribute Details
#data_sets ⇒ Object
Returns the value of attribute data_sets.
24 25 26 |
# File 'lib/smart_chart/encoder.rb', line 24 def data_sets @data_sets end |
#max ⇒ Object
Returns the value of attribute max.
24 25 26 |
# File 'lib/smart_chart/encoder.rb', line 24 def max @max end |
#min ⇒ Object
Returns the value of attribute min.
24 25 26 |
# File 'lib/smart_chart/encoder.rb', line 24 def min @min end |
Instance Method Details
#to_s ⇒ Object
The data, encoded as a string (eg: “s:e5Gf4”).
35 36 37 |
# File 'lib/smart_chart/encoder.rb', line 35 def to_s token + ":" + encode end |