Sha256: d0b03a00ead58f696c8ed6d0ec2b3bb0d6a9913d125c0563c86f982b0c26e351

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

# Add ValueFormat to DataSeries and to individual data points
# Good resource on significant figures:
# * http://www.edu.pe.ca/gray/class_pages/krcutcliffe/physics521/sigfigs/sigfigRULES.htm
# * http://en.wikipedia.org/wiki/Significant_figures
class RailsDataExplorer
  module Utils
    class ValueFormatter

      attr_accessor :d3_format, :ruby_formatter, :significant_figures

      # @param[Object] context
      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

    private

      def initialize_from_data_series(data_series)
      end

      def initialize_from_options(options)
        @d3_format = options[:d3_format]
        @significant_figures = options[:significant_figures]
        @ruby_formatter = options[:ruby_formatter]
      end

      def initialize_from_single_value(options)
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails-data-explorer-0.2.3 lib/rails-data-explorer/utils/value_formatter.rb
rails-data-explorer-0.2.2 lib/rails-data-explorer/utils/value_formatter.rb
rails-data-explorer-0.2.1 lib/rails-data-explorer/utils/value_formatter.rb
rails-data-explorer-0.2.0 lib/rails-data-explorer/utils/value_formatter.rb
rails-data-explorer-0.1.0 lib/rails-data-explorer/utils/value_formatter.rb
rails-data-explorer-0.0.1 lib/rails-data-explorer/utils/value_formatter.rb