Class: SmartChart::Encoder::Base

Inherits:
Object
  • Object
show all
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

Direct Known Subclasses

Extended, Simple, Text

Instance Attribute Summary collapse

Instance Method Summary collapse

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_setsObject

Returns the value of attribute data_sets.



24
25
26
# File 'lib/smart_chart/encoder.rb', line 24

def data_sets
  @data_sets
end

#maxObject

Returns the value of attribute max.



24
25
26
# File 'lib/smart_chart/encoder.rb', line 24

def max
  @max
end

#minObject

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_sObject

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