class PodcastFinder::Category
Attributes
name[RW]
podcasts[RW]
url[RW]
Public Class Methods
all()
click to toggle source
# File lib/podcast_finder/category.rb, line 17 def self.all @@all end
create_from_collection(category_array)
click to toggle source
# File lib/podcast_finder/category.rb, line 26 def self.create_from_collection(category_array) category_array.each {|category_hash| self.new(category_hash)} end
list_categories()
click to toggle source
# File lib/podcast_finder/category.rb, line 30 def self.list_categories self.all.each_with_index do |category, index| puts "(#{index + 1}) #{category.name}" end end
new(category_hash)
click to toggle source
# File lib/podcast_finder/category.rb, line 7 def initialize(category_hash) category_hash.each {|key, value| self.send("#{key}=", value)} @podcasts = [] self.save end
Public Instance Methods
add_podcast(podcast)
click to toggle source
# File lib/podcast_finder/category.rb, line 21 def add_podcast(podcast) self.podcasts << podcast podcast.add_category(self) end
list_podcasts(number)
click to toggle source
# File lib/podcast_finder/category.rb, line 36 def list_podcasts(number) counter = 1 + number podcast_list_count = 0 until counter > (number + 10) do if counter <= self.podcasts.size podcast = self.podcasts[counter - 1] puts "(#{counter}) #{podcast.name}" counter += 1 podcast_list_count += 1 else counter += 10 end end podcast_list_count end
save()
click to toggle source
# File lib/podcast_finder/category.rb, line 13 def save @@all << self end