Sha256: 04748f21a270082451552efc3939979116332fa2f8bc4a5bbb249b5af86f5650

Contents?: true

Size: 403 Bytes

Versions: 4

Compression:

Stored size: 403 Bytes

Contents

# frozen_string_literal: true

module TTFunk
  class Max < Aggregate
    attr_reader :value

    def initialize(init_value = nil)
      @value = init_value
    end

    def <<(new_value)
      new_value = coerce(new_value)

      if value.nil? || new_value > value
        @value = new_value
      end
    end

    def value_or(default)
      return default if value.nil?

      value
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ttfunk-1.6.2.1 lib/ttfunk/max.rb
ttfunk-1.6.2 lib/ttfunk/max.rb
ttfunk-1.6.1 lib/ttfunk/max.rb
ttfunk-1.6.0 lib/ttfunk/max.rb