Class: Dirble::Station
- Inherits:
-
Object
- Object
- Dirble::Station
- Extended by:
- SimpleApiModel
- Defined in:
- lib/dirble/station.rb
Constant Summary collapse
- REQUIRED_FIELDS =
[:name, :website, :directory]
Instance Attribute Summary collapse
-
#bitrate ⇒ Object
Returns the value of attribute bitrate.
-
#categories ⇒ Object
Returns the value of attribute categories.
-
#country ⇒ Object
Returns the value of attribute country.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#song_history ⇒ Object
readonly
Returns the value of attribute song_history.
-
#status ⇒ Object
Returns the value of attribute status.
-
#stream_url ⇒ Object
Returns the value of attribute stream_url.
-
#url_id ⇒ Object
Returns the value of attribute url_id.
-
#website ⇒ Object
Returns the value of attribute website.
Class Method Summary collapse
- .by_continent(name) ⇒ Object
- .by_country(code) ⇒ Object
- .by_country_name(country_name) ⇒ Object
- .count ⇒ Object
- .create(params) ⇒ Object
- .find(station_id) ⇒ Object
- .search(keyword) ⇒ Object
Instance Method Summary collapse
-
#initialize(options) ⇒ Station
constructor
A new instance of Station.
Methods included from SimpleApiModel
build_from_api_response, call_api_with_results, parsed_collection
Constructor Details
#initialize(options) ⇒ Station
Returns a new instance of Station.
13 14 15 16 17 18 19 20 21 |
# File 'lib/dirble/station.rb', line 13 def initialize() self.id = [:id] self.name = [:name] self.website = [:website] self.country = [:country] self.bitrate = [:bitrate] self.status = [:status] self.song_history = Array([:songhistory]) end |
Instance Attribute Details
#bitrate ⇒ Object
Returns the value of attribute bitrate.
9 10 11 |
# File 'lib/dirble/station.rb', line 9 def bitrate @bitrate end |
#categories ⇒ Object
Returns the value of attribute categories.
9 10 11 |
# File 'lib/dirble/station.rb', line 9 def categories @categories end |
#country ⇒ Object
Returns the value of attribute country.
9 10 11 |
# File 'lib/dirble/station.rb', line 9 def country @country end |
#description ⇒ Object
Returns the value of attribute description.
9 10 11 |
# File 'lib/dirble/station.rb', line 9 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
9 10 11 |
# File 'lib/dirble/station.rb', line 9 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/dirble/station.rb', line 9 def name @name end |
#song_history ⇒ Object
Returns the value of attribute song_history.
11 12 13 |
# File 'lib/dirble/station.rb', line 11 def song_history @song_history end |
#status ⇒ Object
Returns the value of attribute status.
9 10 11 |
# File 'lib/dirble/station.rb', line 9 def status @status end |
#stream_url ⇒ Object
Returns the value of attribute stream_url.
9 10 11 |
# File 'lib/dirble/station.rb', line 9 def stream_url @stream_url end |
#url_id ⇒ Object
Returns the value of attribute url_id.
9 10 11 |
# File 'lib/dirble/station.rb', line 9 def url_id @url_id end |
#website ⇒ Object
Returns the value of attribute website.
9 10 11 |
# File 'lib/dirble/station.rb', line 9 def website @website end |
Class Method Details
.by_continent(name) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/dirble/station.rb', line 54 def by_continent(name) call_api_with_results( request_type: :get, query: "continent/apikey/{{api_key}}/continent/#{name.parameterize}" ) end |
.by_country(code) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/dirble/station.rb', line 61 def by_country(code) call_api_with_results( request_type: :get, query: "country/apikey/{{api_key}}/country/#{code}" ) end |
.by_country_name(country_name) ⇒ Object
68 69 70 71 |
# File 'lib/dirble/station.rb', line 68 def by_country_name(country_name) code = IsoCountryCodes.search_by_name(country_name).first.alpha2 by_country(code) end |
.count ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/dirble/station.rb', line 73 def count response = Dirble.connection.exec_query( request_type: :get, query: 'amountStation/apikey/{{api_key}}' ).body JSON.parse(response)['amount'] end |
.create(params) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/dirble/station.rb', line 31 def create(params) guard_creation_of_station(params) call_api_with_results( request_type: :post, query: 'station/apikey/{{api_key}}', form_fields: params ).first end |
.find(station_id) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/dirble/station.rb', line 40 def find(station_id) call_api_with_results( request_type: :get, query: "station/apikey/{{api_key}}/id/#{station_id}" ).first end |
.search(keyword) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/dirble/station.rb', line 47 def search(keyword) call_api_with_results( request_type: :get, query: "search/apikey/{{api_key}}/search/#{keyword.parameterize}" ) end |