Class: RCharts::GraphHelper::Graph::Axis::Caster

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/rcharts/graph_helper/graph/axis/caster.rb

Overview

:nodoc:

Constant Summary collapse

EPOCH_OFFSET =
Time.at(0, in: 'Z').to_date.jd

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Caster

Returns a new instance of Caster.



10
11
12
# File 'app/helpers/rcharts/graph_helper/graph/axis/caster.rb', line 10

def initialize(value)
  @value = value
end

Instance Method Details

#casting ⇒ Object



14
15
16
# File 'app/helpers/rcharts/graph_helper/graph/axis/caster.rb', line 14

def casting
  upcast(yield downcast)
end

#downcast ⇒ Object



18
19
20
21
22
23
24
# File 'app/helpers/rcharts/graph_helper/graph/axis/caster.rb', line 18

def downcast
  case value
  when Time then value.to_i
  when Date then julian_days.to_i
  else value
  end
end