Class: TTFunk::Min
Overview
Minimum aggregate. Its value can only become lower.
Instance Attribute Summary collapse
-
#value ⇒ Comparable?
readonly
Value.
Instance Method Summary collapse
-
#<<(new_value) ⇒ void
Push a value.
-
#initialize(init_value = nil) ⇒ Min
constructor
A new instance of Min.
-
#value_or(default) ⇒ any
Get the stored value or default.
Constructor Details
#initialize(init_value = nil) ⇒ Min
Returns a new instance of Min.
Source Code
lib/ttfunk/min.rb, line 12
12 | def initialize(init_value = nil) |
13 | super() |
14 | @value = init_value |
15 | end
|
Instance Attribute Details
#value ⇒ Comparable? (readonly)
Value
Source Code
lib/ttfunk/min.rb, line 9
9 | def value |
10 | @value
|
11 | end
|
Instance Method Details
#<<(new_value) ⇒ void
This method returns an undefined value.
Push a value. It will become the new value if it’s lower than the current value (or if there was no value).
Source Code
lib/ttfunk/min.rb, line 22
22 | def <<(new_value) |
23 | new_value = coerce(new_value) |
24 | |
25 | if value.nil? || new_value < value |
26 | @value = new_value |
27 | end
|
28 | end
|
#value_or(default) ⇒ any
Get the stored value or default.
Source Code
lib/ttfunk/min.rb, line 34
34 | def value_or(default) |
35 | return default if value.nil? |
36 | |
37 | value
|
38 | end
|