Class: TellyReviews::Review
- Inherits:
-
Object
- Object
- TellyReviews::Review
- Defined in:
- lib/telly_reviews/review.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#author_twitter ⇒ Object
Returns the value of attribute author_twitter.
-
#body ⇒ Object
Returns the value of attribute body.
-
#date ⇒ Object
Returns the value of attribute date.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ Review
constructor
A new instance of Review.
- #review_details ⇒ Object
Constructor Details
#initialize(hash = {}) ⇒ Review
Returns a new instance of Review.
6 7 8 9 10 11 |
# File 'lib/telly_reviews/review.rb', line 6 def initialize(hash={}) hash.each do |k,v| self.send("#{k}=", v) end @@all << self end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
2 3 4 |
# File 'lib/telly_reviews/review.rb', line 2 def @author end |
#author_twitter ⇒ Object
Returns the value of attribute author_twitter.
2 3 4 |
# File 'lib/telly_reviews/review.rb', line 2 def @author_twitter end |
#body ⇒ Object
Returns the value of attribute body.
2 3 4 |
# File 'lib/telly_reviews/review.rb', line 2 def body @body end |
#date ⇒ Object
Returns the value of attribute date.
2 3 4 |
# File 'lib/telly_reviews/review.rb', line 2 def date @date end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/telly_reviews/review.rb', line 2 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/telly_reviews/review.rb', line 2 def url @url end |
Class Method Details
.all ⇒ Object
13 14 15 |
# File 'lib/telly_reviews/review.rb', line 13 def self.all @@all end |
.find(index) ⇒ Object
25 26 27 |
# File 'lib/telly_reviews/review.rb', line 25 def self.find(index) self.all[index-1] end |
Instance Method Details
#review_details ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/telly_reviews/review.rb', line 17 def review_details doc = Nokogiri::HTML(open(self.url)) @date = doc.css(".article-body .abstract .timestamp").text @author_twitter = doc.css(".byline .author .url a").text @body = doc.css(".article-body .variety-content-wrapper").text.strip end |