Class: NowShowing::Show
- Inherits:
-
Object
- Object
- NowShowing::Show
- Defined in:
- lib/now_showing/showing.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#about ⇒ Object
Returns the value of attribute about.
-
#gross ⇒ Object
Returns the value of attribute gross.
-
#link ⇒ Object
Returns the value of attribute link.
-
#metascore ⇒ Object
Returns the value of attribute metascore.
-
#name ⇒ Object
Returns the value of attribute name.
-
#weekend ⇒ Object
Returns the value of attribute weekend.
Class Method Summary collapse
- .all ⇒ Object
-
.more_info(movie) ⇒ Object
scrapes movie page for addtional movie info.
- .reset ⇒ Object
- .scrape_now_showing ⇒ Object
Instance Method Summary collapse
-
#initialize(name, weekend, gross, link, about = nil, metascore = nil) ⇒ Show
constructor
A new instance of Show.
Constructor Details
#initialize(name, weekend, gross, link, about = nil, metascore = nil) ⇒ Show
Returns a new instance of Show.
7 8 9 10 11 12 13 14 15 |
# File 'lib/now_showing/showing.rb', line 7 def initialize(name,weekend,gross,link,about=nil,=nil) @name=name @weekend=weekend @gross=gross @link=link @about=about @metascore= @@all << self end |
Instance Attribute Details
#about ⇒ Object
Returns the value of attribute about.
3 4 5 |
# File 'lib/now_showing/showing.rb', line 3 def about @about end |
#gross ⇒ Object
Returns the value of attribute gross.
3 4 5 |
# File 'lib/now_showing/showing.rb', line 3 def gross @gross end |
#link ⇒ Object
Returns the value of attribute link.
3 4 5 |
# File 'lib/now_showing/showing.rb', line 3 def link @link end |
#metascore ⇒ Object
Returns the value of attribute metascore.
3 4 5 |
# File 'lib/now_showing/showing.rb', line 3 def @metascore end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/now_showing/showing.rb', line 3 def name @name end |
#weekend ⇒ Object
Returns the value of attribute weekend.
3 4 5 |
# File 'lib/now_showing/showing.rb', line 3 def weekend @weekend end |
Class Method Details
.all ⇒ Object
32 33 34 |
# File 'lib/now_showing/showing.rb', line 32 def self.all @@all end |
.more_info(movie) ⇒ Object
scrapes movie page for addtional movie info
41 42 43 44 45 |
# File 'lib/now_showing/showing.rb', line 41 def self.more_info(movie) doc = Nokogiri::HTML(open(movie.link)) movie.about = doc.css('.summary_text').text.gsub("\n",' ').squeeze(' ') movie. = doc.css('.metacriticScore').text.gsub("\n",' ').squeeze(' ') end |
.reset ⇒ Object
36 37 38 |
# File 'lib/now_showing/showing.rb', line 36 def self.reset self.all.clear end |
.scrape_now_showing ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/now_showing/showing.rb', line 17 def self.scrape_now_showing doc = Nokogiri::HTML(open("http://www.imdb.com/chart/boxoffice?ref_=nv_ch_cht_1 ")) doc.css("#boxoffice").css('tr').each do |movie| #checks if the table row contains movie info if movie.css('.ratingColumn')[0] && movie.css('.titleColumn') && movie.css('.ratingColumn')[1] name = movie.css('.titleColumn').text.gsub("\n",' ').squeeze(' ') weekend = movie.css('.ratingColumn')[0].text.gsub("\n",' ').squeeze(' ') gross = movie.css('.ratingColumn')[1].text.gsub("\n",' ').squeeze(' ') link="http://www.imdb.com#{movie.css(".posterColumn").css('td')[0].css('a')[0]['href']}" self.new(name,weekend,gross,link) end end end |