Class: ICheckMovies
- Inherits:
-
Object
- Object
- ICheckMovies
- Defined in:
- lib/icheckmovies.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(url) ⇒ ICheckMovies
constructor
A new instance of ICheckMovies.
- #movies ⇒ Object
- #name ⇒ Object
Constructor Details
#initialize(url) ⇒ ICheckMovies
Returns a new instance of ICheckMovies.
7 8 9 10 |
# File 'lib/icheckmovies.rb', line 7 def initialize(url) @url = url @movie = Struct.new(:imdb_link, :title, :year, :details, :id, :order) end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/icheckmovies.rb', line 5 def url @url end |
Class Method Details
.fetch(url) ⇒ Object
12 13 14 |
# File 'lib/icheckmovies.rb', line 12 def self.fetch(url) ICheckMovies.new(url) end |
Instance Method Details
#movies ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/icheckmovies.rb', line 16 def movies @_movies ||= content.css("li.movie").map do |movie| @movie.new( movie.at_css("a.optionIMDB").attr("href"), movie.at_css("h2 a").content, movie.at_css("a.tagNamespaceYear").content.to_i, "http://www.icheckmovies.com" + movie.at_css("a.dvdCoverSmall").attr("href"), movie.at_css("a.optionIMDB").attr("href").match(/(tt\d{7})/).to_a[1], movie.at_css(".rank") ? movie.at_css(".rank").content.to_i : 0 ) end end |
#name ⇒ Object
28 29 30 |
# File 'lib/icheckmovies.rb', line 28 def name @_name ||= content.at_css("h1").content end |