Class: Dentaku::AST::Count

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

Constant Summary

Constants inherited from Function

Function::DIG

Instance Method Summary collapse

Methods inherited from Function

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

Methods inherited from Node

arity, #dependencies, peek, precedence

Constructor Details

This class inherits a constructor from Dentaku::AST::Function

Instance Method Details

#value(context = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/dentaku/ast/functions/count.rb', line 6

def value(context = {})
  if @args.length == 1
    first_arg = @args[0].value(context)
    return first_arg.length if first_arg.respond_to?(:length)
  end

  @args.length
end