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

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Caster

Returns a new instance of Caster.



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

def initialize(value)
  @value = value
end

Instance Method Details

#castingObject



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

def casting
  upcast(yield downcast)
end

#downcastObject



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

def downcast
  case value
  when Time then value.to_i
  when Date then value.jd + value.day_fraction
  else value
  end
end