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, side_length) ⇒ Bounds
constructor
A new instance of Bounds.
Constructor Details
#initialize(latitude, longitude, side_length) ⇒ Bounds
Returns a new instance of Bounds.
3 4 5 6 7 |
# File 'lib/clumpy/bounds.rb', line 3 def initialize(latitude, longitude, side_length) side_length ||= 10 @latitude = (latitude - side_length)..(latitude + side_length) @longitude = (longitude - side_length*2)..(longitude + side_length*2) end |
Instance Attribute Details
#latitude ⇒ Object (readonly)
Returns the value of attribute latitude.
9 10 11 |
# File 'lib/clumpy/bounds.rb', line 9 def latitude @latitude end |
#longitude ⇒ Object (readonly)
Returns the value of attribute longitude.
11 12 13 |
# File 'lib/clumpy/bounds.rb', line 11 def longitude @longitude end |
Instance Method Details
#as_json ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/clumpy/bounds.rb', line 13 def as_json(*) { northeast: { latitude: @latitude.end, longitude: @longitude.end, }, southwest: { latitude: @latitude.begin, longitude: @longitude.begin, } } end |