Class: Flipper::Types::Percentage
- Inherits:
-
Flipper::Type
- Object
- Flipper::Type
- Flipper::Types::Percentage
- Defined in:
- lib/flipper/types/percentage.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
-
#initialize(value) ⇒ Percentage
constructor
A new instance of Percentage.
Constructor Details
#initialize(value) ⇒ Percentage
Returns a new instance of Percentage.
6 7 8 9 10 11 12 13 14 |
# File 'lib/flipper/types/percentage.rb', line 6 def initialize(value) value = value.to_i if value < 0 || value > 100 raise ArgumentError, "value must be a positive number less than or equal to 100, but was #{value}" end @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/flipper/types/percentage.rb', line 4 def value @value end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
16 17 18 |
# File 'lib/flipper/types/percentage.rb', line 16 def eql?(other) self.class.eql?(other.class) && value == other.value end |