Class: Dentaku::AST::StringFunctions::Find
- Defined in:
- lib/dentaku/ast/functions/string_functions.rb
Constant Summary
Constants inherited from Function
Constants inherited from Node
Node::STATIC_CONTEXT, Node::STATIC_MODE_KEY
Instance Attribute Summary
Attributes inherited from Function
Class Method Summary collapse
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
#accept, #dependencies, get, register, register_class, registry, volatile?
Methods inherited from Node
arity, #dependencies, #name, precedence, #pure?, resolve_class
Constructor Details
#initialize(*args) ⇒ Find
Returns a new instance of Find.
120 121 122 123 |
# File 'lib/dentaku/ast/functions/string_functions.rb', line 120 def initialize(*args) super @needle, @haystack = *@args end |
Class Method Details
.max_param_count ⇒ Object
116 117 118 |
# File 'lib/dentaku/ast/functions/string_functions.rb', line 116 def self.max_param_count 2 end |
.min_param_count ⇒ Object
112 113 114 |
# File 'lib/dentaku/ast/functions/string_functions.rb', line 112 def self.min_param_count 2 end |
Instance Method Details
#type ⇒ Object
133 134 135 |
# File 'lib/dentaku/ast/functions/string_functions.rb', line 133 def type :numeric end |
#value(context = {}) ⇒ Object
125 126 127 128 129 130 131 |
# File 'lib/dentaku/ast/functions/string_functions.rb', line 125 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 |