Class: MLS::Region

Inherits:
Resource show all
Defined in:
lib/mls/models/region.rb

Defined Under Namespace

Classes: Parser

Instance Attribute Summary

Attributes inherited from Resource

#errors, #persisted

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#==, #create!, inherited, #initialize, #new_record?, #persisted?, #properties, #properties_excluded_from_comparison, #properties_for_comparison, #save, #save!, #set_default_values, #to_hash, #to_key, #update!, #update_attributes

Constructor Details

This class inherits a constructor from MLS::Resource

Class Method Details

.find(id) ⇒ Object



23
24
25
26
# File 'lib/mls/models/region.rb', line 23

def find(id)
  response = MLS.get("/regions/#{id}")
  MLS::Region::Parser.parse(response.body)
end

Instance Method Details

#boundsObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/mls/models/region.rb', line 30

def bounds
  return nil unless envelope
  n, e, s, w = nil, nil, nil, nil
  envelope[:coordinates][0].each do |c|
    lon, lat = *c
    n = lat if !n || lat > n
    e = lon if !e || lon > e
    s = lat if !s || lat < s
    w = lon if !w || lon < w
  end
  [n, e, s, w]
end