Class: LocalGeocoder::Geometry::Rect

Inherits:
Struct
  • Object
show all
Defined in:
lib/local_geocoder/geometry/rect.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#heightObject

Returns the value of attribute height

Returns:

  • (Object)

    the current value of height



4
5
6
# File 'lib/local_geocoder/geometry/rect.rb', line 4

def height
  @height
end

#widthObject

Returns the value of attribute width

Returns:

  • (Object)

    the current value of width



4
5
6
# File 'lib/local_geocoder/geometry/rect.rb', line 4

def width
  @width
end

#xObject

Returns the value of attribute x

Returns:

  • (Object)

    the current value of x



4
5
6
# File 'lib/local_geocoder/geometry/rect.rb', line 4

def x
  @x
end

#yObject

Returns the value of attribute y

Returns:

  • (Object)

    the current value of y



4
5
6
# File 'lib/local_geocoder/geometry/rect.rb', line 4

def y
  @y
end

Instance Method Details

#==(rect) ⇒ Object



10
11
12
13
# File 'lib/local_geocoder/geometry/rect.rb', line 10

def ==(rect)
  self.x == rect.x && self.y == rect.y &&
    self.width == rect.width && self.height == rect.height
end

#contains_point?(point) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
# File 'lib/local_geocoder/geometry/rect.rb', line 5

def contains_point?(point)
  point.x >= self.x && point.y >= self.y &&
    point.x <= (self.x+self.width) && point.y <= (self.y+self.height)
end

#inspectObject



15
16
17
# File 'lib/local_geocoder/geometry/rect.rb', line 15

def inspect
  "[#{x},#{y}],[#{x+width},#{y+height}]"
end