Class: OutsideIn::Location
Overview
Location model class.
Locations have the following attributes:
-
category (Category)
-
city
-
display_name
-
lat (Float)
-
lng (Float)
-
state
-
state_abbrev
-
url
-
url_name
-
uuid (SimpleUUID::UUID)
Location finders accept query parameter options as described by #parameterize_url. They return data structures as described by #query_result.
Class Method Summary collapse
-
.named(name, inputs) ⇒ Hash<Symbol, Object>
Returns the locations matching
name
. -
.query_result(data) ⇒ Hash<Symbol, Object>
Returns a hash encapsulating the data returned from a successful finder query.
Instance Method Summary collapse
-
#to_s ⇒ String
Returns the location’s display name and uuid.
Methods inherited from Base
api_attr, api_attrs, #initialize
Constructor Details
This class inherits a constructor from OutsideIn::Base
Class Method Details
.named(name, inputs) ⇒ Hash<Symbol, Object>
Returns the locations matching name
. See the API docs for specifics regarding matching rules.
35 36 37 |
# File 'lib/outside_in/location.rb', line 35 def self.named(name, inputs) query_result(OutsideIn::Resource::LocationFinder.new("/locations/named/#{URI.escape(name)}").GET(inputs)) end |
.query_result(data) ⇒ Hash<Symbol, Object>
Returns a hash encapsulating the data returned from a successful finder query.
The hash contains the following data:
-
:total
- the total number of matching locations (may be greater than the number of returned stories) -
:locations
- the array of best matching OutsideIn::Location as per the specified or implied limit
57 58 59 |
# File 'lib/outside_in/location.rb', line 57 def self.query_result(data) {:total => data['total'], :locations => data['locations'].map {|l| new(l)}} end |
Instance Method Details
#to_s ⇒ String
Returns the location’s display name and uuid.
43 44 45 |
# File 'lib/outside_in/location.rb', line 43 def to_s "#{display_name} (#{uuid.to_guid})" end |