class PodcastFinder::Episode

Attributes

date[RW]
description[RW]
length[RW]
podcast[RW]
title[RW]

Public Class Methods

all() click to toggle source
# File lib/podcast_finder/episode.rb, line 44
def self.all
  @@all
end
create_from_collection(episode_array) click to toggle source
# File lib/podcast_finder/episode.rb, line 22
def self.create_from_collection(episode_array)
  episode_array.each {|episode_hash| self.new(episode_hash)}
end
new(episode_hash) click to toggle source
# File lib/podcast_finder/episode.rb, line 7
def initialize(episode_hash)
  episode_hash.each {|key, value| self.send("#{key}=", value)}
  self.format_date
  self.save
end

Public Instance Methods

display_date() click to toggle source
# File lib/podcast_finder/episode.rb, line 18
def display_date
  @date.strftime('%B %-d, %Y')
end
format_date() click to toggle source
# File lib/podcast_finder/episode.rb, line 13
def format_date
  date_string = @date.to_s
  @date = Date.parse(date_string, "%Y-%m-%d")
end
list_data() click to toggle source
# File lib/podcast_finder/episode.rb, line 26
def list_data
  puts "Episode: #{self.title}".colorize(:light_blue)
  puts "Podcast: ".colorize(:light_blue) + "#{self.podcast.name}"
  puts "Date ".colorize(:light_blue) + "#{self.display_date}"
  if self.length.nil?
    puts "Length: ".colorize(:light_blue) + "Not Available"
  else
    puts "Length: ".colorize(:light_blue) + "#{self.length}"
  end
  puts "Description: ".colorize(:light_blue) + "#{self.description}"
  puts "Link to download: ".colorize(:light_blue) + "#{self.download_link}"
  puts "Link to listen:  ".colorize(:light_blue) + "#{self.podcast.url}"
end
save() click to toggle source
# File lib/podcast_finder/episode.rb, line 40
def save
  @@all << self
end