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.



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

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

Instance Method Details

#typeObject



82
83
84
# File 'lib/dentaku/ast/functions/string_functions.rb', line 82

def type
  :numeric
end

#value(context = {}) ⇒ Object



77
78
79
80
# File 'lib/dentaku/ast/functions/string_functions.rb', line 77

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