Class: Clumpy::Bounds
- Inherits:
-
Object
- Object
- Clumpy::Bounds
- Defined in:
- lib/clumpy/bounds.rb
Instance Attribute Summary collapse
-
#latitude ⇒ Object
readonly
Returns the value of attribute latitude.
-
#longitude ⇒ Object
readonly
Returns the value of attribute longitude.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(latitude, longitude, width, length) ⇒ Bounds
constructor
A new instance of Bounds.
Constructor Details
#initialize(latitude, longitude, width, length) ⇒ Bounds
Returns a new instance of Bounds.
3 4 5 6 7 8 |
# File 'lib/clumpy/bounds.rb', line 3 def initialize(latitude, longitude, width, length) l = length / 2 w = width / 2 @latitude = (latitude - l)..(latitude + l) @longitude = (longitude - w)..(longitude + w) end |
Instance Attribute Details
#latitude ⇒ Object (readonly)
Returns the value of attribute latitude.
10 11 12 |
# File 'lib/clumpy/bounds.rb', line 10 def latitude @latitude end |
#longitude ⇒ Object (readonly)
Returns the value of attribute longitude.
12 13 14 |
# File 'lib/clumpy/bounds.rb', line 12 def longitude @longitude end |
Instance Method Details
#as_json ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/clumpy/bounds.rb', line 14 def as_json(*) { northeast: { latitude: @latitude.end, longitude: @longitude.end, }, southwest: { latitude: @latitude.begin, longitude: @longitude.begin, } } end |