Class: Vedeu::Limit

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/geometry/limit.rb

Overview

Forces the value within defined limits.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(v, vn, max, min = 1) ⇒ Vedeu::Limit

Parameters:



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

#maxObject (readonly, private)

Returns the value of attribute max.



38
39
40
# File 'lib/vedeu/geometry/limit.rb', line 38

def max
  @max
end

#minObject (readonly, private)

Returns the value of attribute min.



38
39
40
# File 'lib/vedeu/geometry/limit.rb', line 38

def min
  @min
end

#vObject (readonly, private)

Returns the value of attribute v.



38
39
40
# File 'lib/vedeu/geometry/limit.rb', line 38

def v
  @v
end

#vnObject (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

See Also:

  • #apply


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

#applyFixnum

Returns:



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