Class: Flipper::Types::Percentage

Inherits:
Flipper::Type show all
Defined in:
lib/flipper/types/percentage.rb

Direct Known Subclasses

PercentageOfActors, PercentageOfTime

Instance Attribute Summary

Attributes inherited from Flipper::Type

#value

Instance Method Summary collapse

Methods inherited from Flipper::Type

#eql?, wrap

Constructor Details

#initialize(value) ⇒ Percentage

Returns a new instance of Percentage.



6
7
8
9
10
11
12
13
14
15
# File 'lib/flipper/types/percentage.rb', line 6

def initialize(value)
  value = Typecast.to_number(value)

  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