Class: NowShowing::Opening
- Inherits:
-
Object
- Object
- NowShowing::Opening
- Defined in:
- lib/now_showing/opening.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#about ⇒ Object
Returns the value of attribute about.
-
#metascore ⇒ Object
Returns the value of attribute metascore.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, about, metascore) ⇒ Opening
constructor
A new instance of Opening.
Constructor Details
#initialize(name, about, metascore) ⇒ Opening
Returns a new instance of Opening.
7 8 9 10 11 12 |
# File 'lib/now_showing/opening.rb', line 7 def initialize(name,about,) @name=name @about=about @metascore= @@all << self end |
Instance Attribute Details
#about ⇒ Object
Returns the value of attribute about.
3 4 5 |
# File 'lib/now_showing/opening.rb', line 3 def about @about end |
#metascore ⇒ Object
Returns the value of attribute metascore.
3 4 5 |
# File 'lib/now_showing/opening.rb', line 3 def @metascore end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/now_showing/opening.rb', line 3 def name @name end |
Class Method Details
.all ⇒ Object
30 31 32 |
# File 'lib/now_showing/opening.rb', line 30 def self.all @@all end |
.reset ⇒ Object
34 35 36 |
# File 'lib/now_showing/opening.rb', line 34 def self.reset self.all.clear end |
.scrape ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/now_showing/opening.rb', line 14 def self.scrape doc = Nokogiri::HTML(open("http://www.imdb.com/movies-in-theaters/")) doc.css(".list_item").each do |movie| name = movie.css(".overview-top").css('h4').text.split(" ")[0..-2].join(" ") about = movie.css('.outline').text.strip = movie.css('.metascore').text.strip = "Metacritic score not yet available" if == "" self.new(name,about,) end #remove last ten form list which are the weeks top ten @@all = @@all[0..-11] end |