class TTFunk::Max
Maximum aggregate. Its value can only become greater.
Attributes
Value
@return [Comparable, nil]
Public Class Methods
Source
# File lib/ttfunk/max.rb, line 12 def initialize(init_value = nil) super() @value = init_value end
@param init_value [Comparable] initial value
Calls superclass method
Public Instance Methods
Source
# File lib/ttfunk/max.rb, line 22 def <<(new_value) new_value = coerce(new_value) if value.nil? || new_value > value @value = new_value end end
Push a value. It will become the new value if it’s greater than the current value (or if there was no value).
@param new_value [Comparable] @return [void]
Source
# File lib/ttfunk/max.rb, line 34 def value_or(default) return default if value.nil? value end
Get the stored value or default.
@param default [any] @return [any]