Class: Dentaku::AST::StringFunctions::Right

Inherits:
Function show all
Defined in:
lib/dentaku/ast/functions/string_functions.rb

Instance Method Summary collapse

Methods inherited from Function

#dependencies, get, register, register_class

Methods inherited from Node

arity, #dependencies, precedence

Constructor Details

#initialize(*args) ⇒ Right

Returns a new instance of Right.



20
21
22
23
# File 'lib/dentaku/ast/functions/string_functions.rb', line 20

def initialize(*args)
  super
  @string, @length = *@args
end

Instance Method Details

#value(context = {}) ⇒ Object



25
26
27
28
29
# File 'lib/dentaku/ast/functions/string_functions.rb', line 25

def value(context={})
  string = @string.value(context).to_s
  length = @length.value(context)
  string[length * -1, length] || string
end