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 Attribute Summary

Attributes inherited from Function

#args

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Function

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

Methods inherited from Node

arity, #dependencies, #name, precedence, resolve_class, #type

Constructor Details

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

Class Method Details

.max_param_countObject



10
11
12
# File 'lib/dentaku/ast/functions/count.rb', line 10

def self.max_param_count
  Float::INFINITY
end

.min_param_countObject



6
7
8
# File 'lib/dentaku/ast/functions/count.rb', line 6

def self.min_param_count
  0
end

Instance Method Details

#value(context = {}) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/dentaku/ast/functions/count.rb', line 14

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