Class: PodcastFinder::Station
- Inherits:
-
Object
- Object
- PodcastFinder::Station
- Defined in:
- lib/podcast_finder/station.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#podcasts ⇒ Object
readonly
Returns the value of attribute podcasts.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #add_podcast(podcast) ⇒ Object
-
#initialize(podcast_hash) ⇒ Station
constructor
A new instance of Station.
- #save ⇒ Object
Constructor Details
#initialize(podcast_hash) ⇒ Station
Returns a new instance of Station.
8 9 10 11 12 13 |
# File 'lib/podcast_finder/station.rb', line 8 def initialize(podcast_hash) @name = podcast_hash[:station] @url = podcast_hash[:station_url] @podcasts = [] self.save end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/podcast_finder/station.rb', line 3 def name @name end |
#podcasts ⇒ Object (readonly)
Returns the value of attribute podcasts.
4 5 6 |
# File 'lib/podcast_finder/station.rb', line 4 def podcasts @podcasts end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/podcast_finder/station.rb', line 3 def url @url end |
Class Method Details
.all ⇒ Object
26 27 28 |
# File 'lib/podcast_finder/station.rb', line 26 def self.all @@all end |
.find_by_name(name) ⇒ Object
30 31 32 |
# File 'lib/podcast_finder/station.rb', line 30 def self.find_by_name(name) self.all.detect {|item| item.name == name} end |
Instance Method Details
#add_podcast(podcast) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/podcast_finder/station.rb', line 15 def add_podcast(podcast) if podcast.class == PodcastFinder::Podcast @podcasts << podcast podcast.station = self end end |
#save ⇒ Object
22 23 24 |
# File 'lib/podcast_finder/station.rb', line 22 def save @@all << self end |