Class: LocalGeocoder::Geometry::Rect
- Inherits:
-
Struct
- Object
- Struct
- LocalGeocoder::Geometry::Rect
- Defined in:
- lib/local_geocoder/geometry/rect.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#width ⇒ Object
Returns the value of attribute width.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height
4 5 6 |
# File 'lib/local_geocoder/geometry/rect.rb', line 4 def height @height end |
#width ⇒ Object
Returns the value of attribute width
4 5 6 |
# File 'lib/local_geocoder/geometry/rect.rb', line 4 def width @width end |
#x ⇒ Object
Returns the value of attribute x
4 5 6 |
# File 'lib/local_geocoder/geometry/rect.rb', line 4 def x @x end |
#y ⇒ Object
Returns the value of attribute 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
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 |
#inspect ⇒ Object
15 16 17 |
# File 'lib/local_geocoder/geometry/rect.rb', line 15 def inspect "[#{x},#{y}],[#{x+width},#{y+height}]" end |