Class: Format::Modifier

Inherits:
Object
  • Object
show all
Defined in:
lib/src/format/modifier.rb

Instance Method Summary collapse

Constructor Details

#initialize(yml, helper) ⇒ Modifier

Returns a new instance of Modifier.



5
6
7
8
# File 'lib/src/format/modifier.rb', line 5

def initialize(yml, helper)
  @debug = yml.fetch(:debug, false)
  @helper = helper
end

Instance Method Details

#apply(raw_value, modifiers) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/src/format/modifier.rb', line 10

def apply(raw_value, modifiers)
  [modifiers].flatten.compact.reduce(raw_value) do |value, modifier|
    method_name, params = modifier_props(modifier).values_at(:name, :params)

    modify_value(value, method_name, params)
  end
end