Class: Rant::RantVar::Constraints::IntegerInRange
- Defined in:
- lib/rant/import/var/numbers.rb
Instance Method Summary collapse
- #default ⇒ Object
- #filter(val) ⇒ Object
-
#initialize(range) ⇒ IntegerInRange
constructor
A new instance of IntegerInRange.
- #to_s ⇒ Object
Methods inherited from Integer
Constructor Details
#initialize(range) ⇒ IntegerInRange
Returns a new instance of IntegerInRange.
37 38 39 |
# File 'lib/rant/import/var/numbers.rb', line 37 def initialize(range) @range = range end |
Instance Method Details
#default ⇒ Object
48 49 50 |
# File 'lib/rant/import/var/numbers.rb', line 48 def default @range.min end |
#filter(val) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/rant/import/var/numbers.rb', line 40 def filter(val) i = super if @range === i i else raise ConstraintError.new(self, val) end end |
#to_s ⇒ Object
51 52 53 |
# File 'lib/rant/import/var/numbers.rb', line 51 def to_s super + " #{@range}" end |