Class: SPNet::LowerLimiter
- Defined in:
- lib/spnet/limiters/lower_limiter.rb
Overview
Instance Attribute Summary collapse
-
#inclusive ⇒ Object
readonly
Returns the value of attribute inclusive.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
Instance Method Summary collapse
-
#apply_limit(value, current_value = nil) ⇒ Object
Limit the given value to be at or above @limit.
-
#initialize(limit, inclusive) ⇒ LowerLimiter
constructor
A new instance of LowerLimiter.
Constructor Details
#initialize(limit, inclusive) ⇒ LowerLimiter
Returns a new instance of LowerLimiter.
8 9 10 11 |
# File 'lib/spnet/limiters/lower_limiter.rb', line 8 def initialize limit, inclusive @limit = limit @inclusive = inclusive end |
Instance Attribute Details
#inclusive ⇒ Object (readonly)
Returns the value of attribute inclusive.
6 7 8 |
# File 'lib/spnet/limiters/lower_limiter.rb', line 6 def inclusive @inclusive end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
6 7 8 |
# File 'lib/spnet/limiters/lower_limiter.rb', line 6 def limit @limit end |
Instance Method Details
#apply_limit(value, current_value = nil) ⇒ Object
Limit the given value to be at or above @limit. Ignores the current_value parameter.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/spnet/limiters/lower_limiter.rb', line 14 def apply_limit value, current_value = nil if inclusive if value >= @limit return value else return @limit end else if value > @limit return value else return @limit + Float::EPSILON end end end |