class PodcastFinder::Podcast

Attributes

categories[R]
description[R]
episodes[R]
name[RW]
station[R]
url[RW]

Public Class Methods

all() click to toggle source
# File lib/podcast_finder/podcast.rb, line 55
def self.all
  @@all
end
find_by_name(name) click to toggle source
# File lib/podcast_finder/podcast.rb, line 59
def self.find_by_name(name)
  self.all.detect {|item| item.name == name}
end
new(podcast_hash) click to toggle source
# File lib/podcast_finder/podcast.rb, line 8
def initialize(podcast_hash)
  @name = podcast_hash[:name]
  @url = podcast_hash[:url]
  @description = nil
  @categories = []
  @episodes = []
  self.save
end

Public Instance Methods

add_category(category) click to toggle source
# File lib/podcast_finder/podcast.rb, line 17
def add_category(category)
  if category.class == PodcastFinder::Category && !self.categories.include?(category)
    @categories << category
  end
end
add_episode(episode) click to toggle source
# File lib/podcast_finder/podcast.rb, line 23
def add_episode(episode)
  self.episodes << episode
  episode.podcast = self
end
description=(description) click to toggle source
# File lib/podcast_finder/podcast.rb, line 40
def description=(description)
  @description = description
end
list_data() click to toggle source
# File lib/podcast_finder/podcast.rb, line 44
def list_data
  puts "Podcast: #{self.name}".colorize(:light_blue)
  puts "Station:".colorize(:light_blue) + "#{self.station.name}"
  puts "Description:".colorize(:light_blue) + " #{self.description}"
end
list_episodes() click to toggle source
# File lib/podcast_finder/podcast.rb, line 34
def list_episodes
  self.episodes.each_with_index do |episode, index|
    puts "(#{index + 1}) #{episode.title} - #{episode.display_date}" + "#{" - " + episode.length unless episode.length.nil?}"
  end
end
save() click to toggle source
# File lib/podcast_finder/podcast.rb, line 51
def save
  @@all << self
end
station=(station) click to toggle source
# File lib/podcast_finder/podcast.rb, line 28
def station=(station)
  if station.class == PodcastFinder::Station
    @station = station
  end
end