Class: AtTheMovies::Review
- Inherits:
-
Object
- Object
- AtTheMovies::Review
- Defined in:
- lib/at_the_movies/review.rb
Instance Attribute Summary collapse
-
#classification ⇒ Object
readonly
Returns the value of attribute classification.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#genre ⇒ Object
readonly
Returns the value of attribute genre.
-
#ratings ⇒ Object
readonly
Returns the value of attribute ratings.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(title, classification, date, duration, genre, ratings, url) ⇒ Review
constructor
A new instance of Review.
- #rating(rater = nil) ⇒ Object
- #total_rating ⇒ Object
Constructor Details
#initialize(title, classification, date, duration, genre, ratings, url) ⇒ Review
Returns a new instance of Review.
14 15 16 17 18 19 20 21 22 |
# File 'lib/at_the_movies/review.rb', line 14 def initialize(title, classification, date, duration, genre, , url) @title = title @classification = classification @duration = duration @genre = genre @date = date @ratings = @url = url end |
Instance Attribute Details
#classification ⇒ Object (readonly)
Returns the value of attribute classification.
3 4 5 |
# File 'lib/at_the_movies/review.rb', line 3 def classification @classification end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
3 4 5 |
# File 'lib/at_the_movies/review.rb', line 3 def date @date end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
3 4 5 |
# File 'lib/at_the_movies/review.rb', line 3 def duration @duration end |
#genre ⇒ Object (readonly)
Returns the value of attribute genre.
3 4 5 |
# File 'lib/at_the_movies/review.rb', line 3 def genre @genre end |
#ratings ⇒ Object (readonly)
Returns the value of attribute ratings.
3 4 5 |
# File 'lib/at_the_movies/review.rb', line 3 def @ratings end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
3 4 5 |
# File 'lib/at_the_movies/review.rb', line 3 def title @title end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/at_the_movies/review.rb', line 3 def url @url end |
Class Method Details
.latest ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/at_the_movies/review.rb', line 5 def self.latest page = WWW::Mechanize.new.get('http://www.abc.net.au/atthemovies/review/') page.search('table.sideRating').first.css('a').inject([]) do |array, a| page = AtTheMovies::Parsers.for(a['href'], :only => "review") array << page array end.compact end |
Instance Method Details
#rating(rater = nil) ⇒ Object
24 25 26 27 |
# File 'lib/at_the_movies/review.rb', line 24 def (rater = nil) return unless rater @ratings[rater.to_s.capitalize] end |
#total_rating ⇒ Object
29 30 31 |
# File 'lib/at_the_movies/review.rb', line 29 def @ratings.inject(0) { |i,p| i += p[1]; i } end |