Class: Boundy::Bound::Constrainer

Inherits:
Object
  • Object
show all
Defined in:
lib/boundy/bound/constrainer.rb

Instance Method Summary collapse

Constructor Details

#initialize(a, b) ⇒ Constrainer

Returns a new instance of Constrainer.



6
7
8
9
10
# File 'lib/boundy/bound/constrainer.rb', line 6

def initialize(a, b)
  @a = a
  @b = b
  @comparator = Boundy::Bound::Comparator.new(a,b)
end

Instance Method Details

#maxObject



12
13
14
15
16
17
18
# File 'lib/boundy/bound/constrainer.rb', line 12

def max
  if @comparator.compare == :left
    @a
  else
    @b
  end
end

#minObject



20
21
22
23
24
25
26
# File 'lib/boundy/bound/constrainer.rb', line 20

def min
  if @comparator.compare == :right
    @a
  else
    @b
  end
end