Class: Axiom::Aggregate::Maximum

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

Overview

The maximum value in a sequence of numbers

Defined Under Namespace

Modules: Methods

Constant Summary collapse

DEFAULT =
-Float::INFINITY

Instance Attribute Summary

Attributes included from Operation::Unary

#operand

Class Method Summary collapse

Instance 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

Methods included from Visitable

#accept

Class Method Details

.call(maximum, value) ⇒ Numeric

Return the maximum value for a sequence of numbers

Examples:

maximum = Maximum.call(maximum, value)

Parameters:

Returns:



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

def self.call(maximum, value)
  return maximum if value.nil?
  value > maximum ? value : maximum
end

Instance Method Details

#typeClass<Types::Numeric>

Return the type returned from #call

Examples:

type = aggregate.type  # => Axiom::Types::Numeric

Returns:

  • (Class<Types::Numeric>)


36
37
38
# File 'lib/axiom/aggregate/maximum.rb', line 36

def type
  Attribute.infer_type(operand)
end