Class: Axiom::Aggregate::Count

Inherits:
Axiom::Aggregate show all
Defined in:
lib/axiom/aggregate/count.rb

Overview

The count of a series of values

Defined Under Namespace

Modules: Methods

Constant Summary collapse

DEFAULT =
0

Instance Attribute Summary

Attributes included from Operation::Unary

#operand

Class Method Summary collapse

Methods inherited from Axiom::Aggregate

#call, #default, default, finalize, #finalize

Methods included from Operation::Unary

#initialize

Methods inherited from Function

extract_value, rename_attributes, #type

Methods included from Visitable

#accept

Class Method Details

.call(count, value) ⇒ Integer

Return the count for a series of values

Examples:

count = Count.call(count, value)

Parameters:

  • count (Integer)
  • value (Object)

Returns:

  • (Integer)


23
24
25
# File 'lib/axiom/aggregate/count.rb', line 23

def self.call(count, value)
  value.nil? ? count : count.succ
end

.typeClass<Types::Integer>

Return the type returned from #call

Examples:

type = Axiom::Aggregate::Count.type  # => Axiom::Types::Integer

Returns:

  • (Class<Types::Integer>)


35
36
37
# File 'lib/axiom/aggregate/count.rb', line 35

def self.type
  Types::Integer
end