Class: PodcastFinder::Episode
- Inherits:
-
Object
- Object
- PodcastFinder::Episode
- Defined in:
- lib/podcast_finder/episode.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#description ⇒ Object
Returns the value of attribute description.
-
#download_link ⇒ Object
Returns the value of attribute download_link.
-
#length ⇒ Object
Returns the value of attribute length.
-
#podcast ⇒ Object
Returns the value of attribute podcast.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #display_date ⇒ Object
- #format_date ⇒ Object
-
#initialize(episode_hash) ⇒ Episode
constructor
A new instance of Episode.
- #list_data ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(episode_hash) ⇒ Episode
Returns a new instance of Episode.
7 8 9 10 11 |
# 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 |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
3 4 5 |
# File 'lib/podcast_finder/episode.rb', line 3 def date @date end |
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/podcast_finder/episode.rb', line 3 def description @description end |
#download_link ⇒ Object
Returns the value of attribute download_link.
3 4 5 |
# File 'lib/podcast_finder/episode.rb', line 3 def download_link @download_link end |
#length ⇒ Object
Returns the value of attribute length.
3 4 5 |
# File 'lib/podcast_finder/episode.rb', line 3 def length @length end |
#podcast ⇒ Object
Returns the value of attribute podcast.
3 4 5 |
# File 'lib/podcast_finder/episode.rb', line 3 def podcast @podcast end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/podcast_finder/episode.rb', line 3 def title @title end |
Class Method Details
.all ⇒ Object
44 45 46 |
# File 'lib/podcast_finder/episode.rb', line 44 def self.all @@all end |
.create_from_collection(episode_array) ⇒ Object
22 23 24 |
# 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 |
Instance Method Details
#display_date ⇒ Object
18 19 20 |
# File 'lib/podcast_finder/episode.rb', line 18 def display_date @date.strftime('%B %-d, %Y') end |
#format_date ⇒ Object
13 14 15 16 |
# 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 ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# 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 ⇒ Object
40 41 42 |
# File 'lib/podcast_finder/episode.rb', line 40 def save @@all << self end |