Class: Vedeu::Limit
- Inherits:
-
Object
- Object
- Vedeu::Limit
- Defined in:
- lib/vedeu/geometry/limit.rb
Overview
Forces the value within defined limits.
Instance Attribute Summary collapse
-
#max ⇒ Object
readonly
private
Returns the value of attribute max.
-
#min ⇒ Object
readonly
private
Returns the value of attribute min.
-
#v ⇒ Object
readonly
private
Returns the value of attribute v.
-
#vn ⇒ Object
readonly
private
Returns the value of attribute vn.
Class Method Summary collapse
Instance Method Summary collapse
Constructor Details
#initialize(v, vn, max, min = 1) ⇒ Vedeu::Limit
17 18 19 20 21 22 |
# File 'lib/vedeu/geometry/limit.rb', line 17 def initialize(v, vn, max, min = 1) @v = v @vn = vn @max = max @min = min || 1 end |
Instance Attribute Details
#max ⇒ Object (readonly, private)
Returns the value of attribute max.
38 39 40 |
# File 'lib/vedeu/geometry/limit.rb', line 38 def max @max end |
#min ⇒ Object (readonly, private)
Returns the value of attribute min.
38 39 40 |
# File 'lib/vedeu/geometry/limit.rb', line 38 def min @min end |
#v ⇒ Object (readonly, private)
Returns the value of attribute v.
38 39 40 |
# File 'lib/vedeu/geometry/limit.rb', line 38 def v @v end |
#vn ⇒ Object (readonly, private)
Returns the value of attribute vn.
38 39 40 |
# File 'lib/vedeu/geometry/limit.rb', line 38 def vn @vn end |
Class Method Details
.apply(v, vn, max, min = 1) ⇒ Object
8 9 10 |
# File 'lib/vedeu/geometry/limit.rb', line 8 def self.apply(v, vn, max, min = 1) new(v, vn, max, min).apply end |
Instance Method Details
#apply ⇒ Fixnum
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vedeu/geometry/limit.rb', line 25 def apply if (v + vn) > max applied = vn - ((v + vn) - max) return applied < min ? min : applied else vn end end |