Class: Bing::Location
- Inherits:
-
RestResource
- Object
- RestResource
- Bing::Location
- Defined in:
- lib/bing/location.rb
Overview
Responsible for obtaining a location based off of data passed in.
Constant Summary
Constants inherited from RestResource
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#canonical_description ⇒ Object
readonly
Returns the value of attribute canonical_description.
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#confidence ⇒ Object
readonly
Returns the value of attribute confidence.
-
#coordinates ⇒ Object
readonly
Returns the value of attribute coordinates.
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#entity_type ⇒ Object
readonly
Returns the value of attribute entity_type.
-
#full_name ⇒ Object
readonly
Returns the value of attribute full_name.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#zip ⇒ Object
readonly
Returns the value of attribute zip.
Attributes inherited from RestResource
Class Method Summary collapse
-
.find(opts) ⇒ Object
Will find locations based off of
query
and return an array of Bing::Location objects. -
.path ⇒ Object
Path to route resource.
Instance Method Summary collapse
-
#initialize(resource) ⇒ Location
constructor
A new instance of Location.
Methods inherited from RestResource
Constructor Details
#initialize(resource) ⇒ Location
Returns a new instance of Location.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/bing/location.rb', line 38 def initialize resource raise Bing::LocationResourceMissing if resource.blank? @confidence = resource['confidence'] @entity_type = resource['entityType'] @full_name = resource['name'] if resource['address'] then @address = resource['address']['addressLine'] @city = resource['address']['locality'] @country = resource['address']['countryRegion'] @state = resource['address']['adminDistrict'] @zip = resource['address']['postalCode'] end if resource['bbox'] then @bounding_box = bbox resource['bbox'] end if resource['point'] && resource['point']['coordinates'] then @coordinates = resource['point']['coordinates'] end end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
27 28 29 |
# File 'lib/bing/location.rb', line 27 def address @address end |
#canonical_description ⇒ Object (readonly)
Returns the value of attribute canonical_description.
28 29 30 |
# File 'lib/bing/location.rb', line 28 def canonical_description @canonical_description end |
#city ⇒ Object (readonly)
Returns the value of attribute city.
30 31 32 |
# File 'lib/bing/location.rb', line 30 def city @city end |
#confidence ⇒ Object (readonly)
Returns the value of attribute confidence.
31 32 33 |
# File 'lib/bing/location.rb', line 31 def confidence @confidence end |
#coordinates ⇒ Object (readonly)
Returns the value of attribute coordinates.
29 30 31 |
# File 'lib/bing/location.rb', line 29 def coordinates @coordinates end |
#country ⇒ Object (readonly)
Returns the value of attribute country.
32 33 34 |
# File 'lib/bing/location.rb', line 32 def country @country end |
#entity_type ⇒ Object (readonly)
Returns the value of attribute entity_type.
33 34 35 |
# File 'lib/bing/location.rb', line 33 def entity_type @entity_type end |
#full_name ⇒ Object (readonly)
Returns the value of attribute full_name.
34 35 36 |
# File 'lib/bing/location.rb', line 34 def full_name @full_name end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
35 36 37 |
# File 'lib/bing/location.rb', line 35 def state @state end |
#zip ⇒ Object (readonly)
Returns the value of attribute zip.
36 37 38 |
# File 'lib/bing/location.rb', line 36 def zip @zip end |
Class Method Details
.find(opts) ⇒ Object
Will find locations based off of query
and return an array of Bing::Location objects. Will support any param that bing supports.
Example
Bing::Location.find :query => ‘123 Address City State’
16 17 18 |
# File 'lib/bing/location.rb', line 16 def self.find opts map_find opts.to_lower_camelized_param end |
.path ⇒ Object
Path to route resource.
23 24 25 |
# File 'lib/bing/location.rb', line 23 def self.path super '/Locations' end |