Class: Rant::RantVar::Constraints::FloatInRange

Inherits:
Float
  • Object
show all
Defined in:
lib/rant/import/var/numbers.rb

Instance Method Summary collapse

Methods inherited from Float

rant_constraint

Constructor Details

#initialize(range) ⇒ FloatInRange

Returns a new instance of FloatInRange.



83
84
85
# File 'lib/rant/import/var/numbers.rb', line 83

def initialize(range)
    @range = range
end

Instance Method Details

#defaultObject



94
95
96
# File 'lib/rant/import/var/numbers.rb', line 94

def default
    @range.first
end

#filter(val) ⇒ Object



86
87
88
89
90
91
92
93
# File 'lib/rant/import/var/numbers.rb', line 86

def filter(val)
    i = super
    if @range === i
	i
    else
	raise ConstraintError.new(self, val)
    end
end

#to_sObject



97
98
99
# File 'lib/rant/import/var/numbers.rb', line 97

def to_s
    super + " #{@range}"
end