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, 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

#latitudeObject (readonly)

Returns the value of attribute latitude.



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

def latitude
  @latitude
end

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



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