class ActiveReporter::Dimension::Number

Constants

DEFAULT_BIN_COUNT

Public Instance Methods

bin_width() click to toggle source
# File lib/active_reporter/dimension/number.rb, line 17
def bin_width
  case
  when params.key?(:bin_width)
    params[:bin_width].to_f
  when domain.zero?
    1
  when params.key?(:bin_count)
    domain / params[:bin_count].to_f
  else
    default_bin_width
  end
end
validate_params!() click to toggle source
# File lib/active_reporter/dimension/number.rb, line 8
def validate_params!
  super

  if params.key?(:bin_width)
    invalid_param!(:bin_width, 'must be numeric') unless ActiveReporter.numeric?(params[:bin_width])
    invalid_param!(:bin_width, 'must be greater than 0') unless params[:bin_width].to_f > 0
  end
end

Private Instance Methods

default_bin_count() click to toggle source
# File lib/active_reporter/dimension/number.rb, line 36
def default_bin_count
  self.class::DEFAULT_BIN_COUNT
end
default_bin_width() click to toggle source
# File lib/active_reporter/dimension/number.rb, line 32
def default_bin_width
  domain / default_bin_count.to_f
end