Class: Dentaku::AST::StringFunctions::Find
- Defined in:
- lib/dentaku/ast/functions/string_functions.rb
Constant Summary
Constants inherited from Function
Instance Method Summary collapse
-
#initialize(*args) ⇒ Find
constructor
A new instance of Find.
- #type ⇒ Object
- #value(context = {}) ⇒ Object
Methods inherited from Base
Methods inherited from Function
#dependencies, get, numeric, register, register_class, registry
Methods inherited from Node
arity, #dependencies, peek, precedence
Constructor Details
#initialize(*args) ⇒ Find
Returns a new instance of Find.
80 81 82 83 |
# File 'lib/dentaku/ast/functions/string_functions.rb', line 80 def initialize(*args) super @needle, @haystack = *@args end |
Instance Method Details
#type ⇒ Object
93 94 95 |
# File 'lib/dentaku/ast/functions/string_functions.rb', line 93 def type :numeric end |
#value(context = {}) ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/dentaku/ast/functions/string_functions.rb', line 85 def value(context = {}) needle = @needle.value(context) needle = needle.to_s unless needle.is_a?(Regexp) haystack = @haystack.value(context).to_s pos = haystack.index(needle) pos && pos + 1 end |