Class: RailsDataExplorer::Utils::ValueFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_data_explorer/utils/value_formatter.rb

Overview

Responsibilities:

* Format values in data series and individual data

Good resource on significant figures:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ ValueFormatter

@param context



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rails_data_explorer/utils/value_formatter.rb', line 17

def initialize(context)
  case context
  when DataSeries
    initialize_from_data_series(context)
  when Hash
    initialize_from_options(context)
  when Numeric
    initialize_from_single_value(context)
  else
    raise "Handle this context: #{ context.inspect }"
  end
end

Instance Attribute Details

#d3_formatObject

Returns the value of attribute d3_format.



14
15
16
# File 'lib/rails_data_explorer/utils/value_formatter.rb', line 14

def d3_format
  @d3_format
end

#ruby_formatterObject

Returns the value of attribute ruby_formatter.



14
15
16
# File 'lib/rails_data_explorer/utils/value_formatter.rb', line 14

def ruby_formatter
  @ruby_formatter
end

#significant_figuresObject

Returns the value of attribute significant_figures.



14
15
16
# File 'lib/rails_data_explorer/utils/value_formatter.rb', line 14

def significant_figures
  @significant_figures
end