class TopTv::Show
Attributes
description[RW]
genre[RW]
name[RW]
network[RW]
premiere_date[RW]
url[RW]
Public Class Methods
all()
click to toggle source
# File lib/top_tv/show.rb, line 19 def self.all @@all end
find_show_by_name(chosen_show)
click to toggle source
# File lib/top_tv/show.rb, line 23 def self.find_show_by_name(chosen_show) self.all.detect { |show| show.name == chosen_show } end
new(name, url)
click to toggle source
# File lib/top_tv/show.rb, line 13 def initialize(name, url) @name = name @url = url @@all << self end
new_from_home_page(show)
click to toggle source
# File lib/top_tv/show.rb, line 6 def self.new_from_home_page(show) self.new( show.text.gsub(" View All ", "").gsub(",", ""), "https://www.rottentomatoes.com#{show.attr("href")}" ) end
Public Instance Methods
doc()
click to toggle source
# File lib/top_tv/show.rb, line 43 def doc @doc ||= Nokogiri::HTML(open(self.url)) end