Class: RiceBubble::Attributes::Integer
- Defined in:
- lib/rice_bubble/attributes/integer.rb
Instance Attribute Summary collapse
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
Instance Method Summary collapse
-
#initialize(min: nil, max: nil, **options) ⇒ Integer
constructor
A new instance of Integer.
- #valid?(value) ⇒ Boolean
- #valid_types ⇒ Object
Methods inherited from Number
Methods inherited from Base
#call, #description, #fetch, #optional
Constructor Details
#initialize(min: nil, max: nil, **options) ⇒ Integer
Returns a new instance of Integer.
6 7 8 9 10 |
# File 'lib/rice_bubble/attributes/integer.rb', line 6 def initialize(min: nil, max: nil, **, &) super(**, &) @min = min @max = max end |
Instance Attribute Details
#max ⇒ Object (readonly)
Returns the value of attribute max.
4 5 6 |
# File 'lib/rice_bubble/attributes/integer.rb', line 4 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
4 5 6 |
# File 'lib/rice_bubble/attributes/integer.rb', line 4 def min @min end |
Instance Method Details
#valid?(value) ⇒ Boolean
16 17 18 19 20 |
# File 'lib/rice_bubble/attributes/integer.rb', line 16 def valid?(value) super && (!min || value >= min) && (!max || value <= max) end |
#valid_types ⇒ Object
12 13 14 |
# File 'lib/rice_bubble/attributes/integer.rb', line 12 def valid_types [::Integer] end |