Class: Locomotive::Steam::Liquid::Filters::Number::NumberProxyHelper

Inherits:
Object
  • Object
show all
Includes:
ActiveSupport::NumberHelper
Defined in:
lib/locomotive/steam/liquid/filters/number.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, context) ⇒ NumberProxyHelper

Returns a new instance of NumberProxyHelper.



27
28
29
30
# File 'lib/locomotive/steam/liquid/filters/number.rb', line 27

def initialize(name, context)
  @name     = name
  @context  = context
end

Instance Method Details

#interpolate_options(options) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/locomotive/steam/liquid/filters/number.rb', line 36

def interpolate_options(options)
  (options || {}).transform_values do |option|
    if option.is_a?(String)
      _option = ::Liquid::Expression.parse(option)
      @context.evaluate(_option) || option
    else
      option
    end
  end
end

#invoke(input, options) ⇒ Object



32
33
34
# File 'lib/locomotive/steam/liquid/filters/number.rb', line 32

def invoke(input, options)
  send :"number_to_#{@name}", input, interpolate_options(options)
end