Class: TopTv::Show
- Inherits:
-
Object
- Object
- TopTv::Show
- Defined in:
- lib/top_tv/show.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#genre ⇒ Object
Returns the value of attribute genre.
-
#name ⇒ Object
Returns the value of attribute name.
-
#network ⇒ Object
Returns the value of attribute network.
-
#premiere_date ⇒ Object
Returns the value of attribute premiere_date.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #doc ⇒ Object
-
#initialize(name, url) ⇒ Show
constructor
A new instance of Show.
Constructor Details
#initialize(name, url) ⇒ Show
Returns a new instance of Show.
13 14 15 16 17 |
# File 'lib/top_tv/show.rb', line 13 def initialize(name, url) @name = name @url = url @@all << self end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/top_tv/show.rb', line 2 def description @description end |
#genre ⇒ Object
Returns the value of attribute genre.
2 3 4 |
# File 'lib/top_tv/show.rb', line 2 def genre @genre end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/top_tv/show.rb', line 2 def name @name end |
#network ⇒ Object
Returns the value of attribute network.
2 3 4 |
# File 'lib/top_tv/show.rb', line 2 def network @network end |
#premiere_date ⇒ Object
Returns the value of attribute premiere_date.
2 3 4 |
# File 'lib/top_tv/show.rb', line 2 def premiere_date @premiere_date end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/top_tv/show.rb', line 2 def url @url end |
Class Method Details
.all ⇒ Object
19 20 21 |
# File 'lib/top_tv/show.rb', line 19 def self.all @@all end |
.find_show_by_name(chosen_show) ⇒ Object
23 24 25 |
# 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_from_home_page(show) ⇒ Object
6 7 8 9 10 11 |
# 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 |
Instance Method Details
#doc ⇒ Object
43 44 45 |
# File 'lib/top_tv/show.rb', line 43 def doc @doc ||= Nokogiri::HTML(open(self.url)) end |