Class: Dentaku::AST::StringFunctions::Substitute
- Defined in:
- lib/dentaku/ast/functions/string_functions.rb
Instance Method Summary collapse
-
#initialize(original, search, replacement) ⇒ Substitute
constructor
A new instance of Substitute.
- #value(context = {}) ⇒ Object
Methods inherited from Function
#dependencies, get, register, register_class
Methods inherited from Node
arity, #dependencies, precedence
Constructor Details
#initialize(original, search, replacement) ⇒ Substitute
Returns a new instance of Substitute.
70 71 72 73 74 |
# File 'lib/dentaku/ast/functions/string_functions.rb', line 70 def initialize(original, search, replacement) @original = original @search = search @replacement = replacement end |
Instance Method Details
#value(context = {}) ⇒ Object
76 77 78 79 80 81 |
# File 'lib/dentaku/ast/functions/string_functions.rb', line 76 def value(context={}) original = @original.value(context) search = @search.value(context) replacement = @replacement.value(context) original.sub(search, replacement) end |