Class: PodcastFinder::Station

Inherits:
Object
  • Object
show all
Defined in:
lib/podcast_finder/station.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/podcast_finder/station.rb', line 3

def name
  @name
end

#podcastsObject (readonly)

Returns the value of attribute podcasts.



4
5
6
# File 'lib/podcast_finder/station.rb', line 4

def podcasts
  @podcasts
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/podcast_finder/station.rb', line 3

def url
  @url
end

Class Method Details

.allObject



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

#saveObject



22
23
24
# File 'lib/podcast_finder/station.rb', line 22

def save
  @@all << self
end