Class: Dentaku::AST::StringFunctions::Len

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) ⇒ Len

Returns a new instance of Len.



47
48
49
50
# File 'lib/dentaku/ast/functions/string_functions.rb', line 47

def initialize(*args)
  super
  @string = @args[0]
end

Instance Method Details

#value(context = {}) ⇒ Object



52
53
54
55
# File 'lib/dentaku/ast/functions/string_functions.rb', line 52

def value(context={})
  string = @string.value(context).to_s
  string.length
end