Class: Shortwave::Model::Location

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/shortwave/model/location.rb

Overview

A location

Attributes

latitude

Latitude

longitude

Longitude

street_address

Street address

city

City

postcode

Post code

country

Country name

Instance Method Summary collapse

Methods inherited from BaseModel

facade_name, identified_by, inherited, link_to, #session=, sharable, shoutable, taggable

Instance Method Details

#artistsObject

Popular artists in this country. Needs country to be defined



22
23
24
# File 'lib/shortwave/model/location.rb', line 22

def artists
  link :top_artists, :Artist, country
end

#eventsObject

Return events near this location



34
35
36
37
38
39
40
41
42
# File 'lib/shortwave/model/location.rb', line 34

def events
  if latitude && longitude
    link :events, :Event, :lat => latitude, :long => longitude
  elsif city
    link :events, :Event, :location => city
  elsif country
    link :events, :Event, :location => country
  end
end

#tracksObject

Popular tracks in this location



27
28
29
30
31
# File 'lib/shortwave/model/location.rb', line 27

def tracks
  args = [country]
  args << {:location => city} if city
  link :top_tracks, :Track, *args
end