Class: Dentaku::AST::StringFunctions::Mid
- Defined in:
- lib/dentaku/ast/functions/string_functions.rb
Instance Method Summary collapse
-
#initialize(*args) ⇒ Mid
constructor
A new instance of Mid.
- #value(context = {}) ⇒ Object
Methods inherited from Function
#dependencies, get, register, register_class, registry
Methods inherited from Node
arity, #dependencies, precedence
Constructor Details
#initialize(*args) ⇒ Mid
Returns a new instance of Mid.
33 34 35 36 |
# File 'lib/dentaku/ast/functions/string_functions.rb', line 33 def initialize(*args) super @string, @offset, @length = *@args end |
Instance Method Details
#value(context = {}) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/dentaku/ast/functions/string_functions.rb', line 38 def value(context={}) string = @string.value(context).to_s offset = @offset.value(context) length = @length.value(context) string[offset - 1, length].to_s end |