Class: Calyx::Modifiers

Inherits:
Object
  • Object
show all
Defined in:
lib/calyx/modifiers.rb

Overview

Applies modifiers to the output of a rule in a template substitution.

Instance Method Summary collapse

Instance Method Details

#lower(value) ⇒ Object



28
29
30
# File 'lib/calyx/modifiers.rb', line 28

def lower(value)
  value.downcase
end

#transform(name, value) ⇒ String

Transforms an output string by delegating to the given output function.

If a registered modifier method is not found, then delegate to the given string function.

If an invalid modifier function is given, returns the raw input string.

Parameters:

  • name (Symbol)
  • value (String)

Returns:

  • (String)


14
15
16
17
18
19
20
21
22
# File 'lib/calyx/modifiers.rb', line 14

def transform(name, value)
  if respond_to?(name)
    send(name, value)
  elsif value.respond_to?(name)
    value.send(name)
  else
    value
  end
end

#upper(value) ⇒ Object



24
25
26
# File 'lib/calyx/modifiers.rb', line 24

def upper(value)
  value.upcase
end