Sha256: 38f5989b8b5a4e79dd52c7224887b920b953320b4d515e8195eff1816f66375a
Contents?: true
Size: 849 Bytes
Versions: 1
Compression:
Stored size: 849 Bytes
Contents
# frozen_string_literal: true module TTFunk # Minimum aggregate. Its value can only become lower. class Min < Aggregate # Value # # @return [Comparable, nil] attr_reader :value # @param init_value [Comparable] initial value def initialize(init_value = nil) super() @value = init_value end # Push a value. It will become the new value if it's lower than the current # value (or if there was no value). # # @param new_value [Comparable] # @return [void] def <<(new_value) new_value = coerce(new_value) if value.nil? || new_value < value @value = new_value end end # Get the stored value or default. # # @param default [any] # @return [any] def value_or(default) return default if value.nil? value end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ttfunk-1.8.0 | lib/ttfunk/min.rb |