Sha256: 9f219ee235c86700e119ea0fe961dac99dbbdac94c18ffbb0dee36ade30b88e3

Contents?: true

Size: 417 Bytes

Versions: 2

Compression:

Stored size: 417 Bytes

Contents

module RiceBubble
  class Attributes
    class Integer < Number
      attr_reader :min, :max

      def initialize(min: nil, max: nil, **options, &)
        super(**options, &)
        @min = min
        @max = max
      end

      def valid_types
        [::Integer]
      end

      def valid?(value)
        super &&
          (!min || value >= min) &&
          (!max || value <= max)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rice_bubble-0.2.1 lib/rice_bubble/attributes/integer.rb
rice_bubble-0.2.0 lib/rice_bubble/attributes/integer.rb