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

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

Constant Summary

Constants inherited from Function

Function::DIG

Instance Method Summary collapse

Methods inherited from Base

#negative_argument_failure

Methods inherited from Function

#dependencies, get, numeric, register, register_class, registry

Methods inherited from Node

arity, #dependencies, peek, precedence

Constructor Details

#initialize(*args) ⇒ Len

Returns a new instance of Len.



64
65
66
67
# File 'lib/dentaku/ast/functions/string_functions.rb', line 64

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

Instance Method Details

#typeObject



74
75
76
# File 'lib/dentaku/ast/functions/string_functions.rb', line 74

def type
  :numeric
end

#value(context = {}) ⇒ Object



69
70
71
72
# File 'lib/dentaku/ast/functions/string_functions.rb', line 69

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