Class: NowShowing::Opening

Inherits:
Object
  • Object
show all
Defined in:
lib/now_showing/opening.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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,metascore)
  @name=name
  @about=about
  @metascore=metascore
  @@all << self
end

Instance Attribute Details

#aboutObject

Returns the value of attribute about.



3
4
5
# File 'lib/now_showing/opening.rb', line 3

def about
  @about
end

#metascoreObject

Returns the value of attribute metascore.



3
4
5
# File 'lib/now_showing/opening.rb', line 3

def metascore
  @metascore
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/now_showing/opening.rb', line 3

def name
  @name
end

Class Method Details

.allObject



30
31
32
# File 'lib/now_showing/opening.rb', line 30

def self.all
  @@all
end

.resetObject



34
35
36
# File 'lib/now_showing/opening.rb', line 34

def self.reset
  self.all.clear
end

.scrapeObject



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
    metascore = movie.css('.metascore').text.strip
    metascore = "Metacritic score not yet available" if metascore == ""
    self.new(name,about,metascore)

  end
  #remove last ten form list which are the weeks top ten

  @@all = @@all[0..-11]
end