Class: Bounds

Inherits:
Struct
  • Object
show all
Defined in:
lib/contrek/finder/bounds.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#max_xObject

Returns the value of attribute max_x

Returns:

  • (Object)

    the current value of max_x



1
2
3
# File 'lib/contrek/finder/bounds.rb', line 1

def max_x
  @max_x
end

#max_yObject

Returns the value of attribute max_y

Returns:

  • (Object)

    the current value of max_y



1
2
3
# File 'lib/contrek/finder/bounds.rb', line 1

def max_y
  @max_y
end

#min_xObject

Returns the value of attribute min_x

Returns:

  • (Object)

    the current value of min_x



1
2
3
# File 'lib/contrek/finder/bounds.rb', line 1

def min_x
  @min_x
end

#min_yObject

Returns the value of attribute min_y

Returns:

  • (Object)

    the current value of min_y



1
2
3
# File 'lib/contrek/finder/bounds.rb', line 1

def min_y
  @min_y
end

Class Method Details

.emptyObject



2
3
4
# File 'lib/contrek/finder/bounds.rb', line 2

def self.empty
  new(Float::INFINITY, -Float::INFINITY, Float::INFINITY, -Float::INFINITY)
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/contrek/finder/bounds.rb', line 14

def empty?
  min_x == Float::INFINITY
end

#expand(x:, y:) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/contrek/finder/bounds.rb', line 6

def expand(x:, y:)
  self.min_x = x if x < min_x
  self.max_x = x if x > max_x
  self.min_y = y if y < min_y
  self.max_y = y if y > max_y
  self
end