Class: Clumpy::Bounds

Inherits:
Object
  • Object
show all
Defined in:
lib/clumpy/bounds.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#latitudeObject (readonly)

Returns the value of attribute latitude.



9
10
11
# File 'lib/clumpy/bounds.rb', line 9

def latitude
  @latitude
end

#longitudeObject (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_jsonObject



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