Class: GameFaqs::Review
- Inherits:
-
Object
- Object
- GameFaqs::Review
- Includes:
- Caching
- Defined in:
- lib/gamefaqs/review.rb
Constant Summary collapse
- REVIEW_TYPES =
[:detailed, :full, :quick]
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#game ⇒ Object
readonly
Returns the value of attribute game.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #created_at ⇒ Object
-
#initialize(options = {}) ⇒ Review
constructor
A new instance of Review.
- #score_to_i ⇒ Object
- #text ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Review
Returns a new instance of Review.
9 10 11 12 |
# File 'lib/gamefaqs/review.rb', line 9 def initialize(={}) raise ArgumentError.new("Need at least the game and the review id") unless [:game] && [:id] @game, @id, @score, @author, @title, @type = [:game], [:id], [:score], [:author], [:title], [:type] end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
7 8 9 |
# File 'lib/gamefaqs/review.rb', line 7 def @author end |
#game ⇒ Object (readonly)
Returns the value of attribute game.
7 8 9 |
# File 'lib/gamefaqs/review.rb', line 7 def game @game end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/gamefaqs/review.rb', line 7 def id @id end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
7 8 9 |
# File 'lib/gamefaqs/review.rb', line 7 def score @score end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/gamefaqs/review.rb', line 7 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/gamefaqs/review.rb', line 7 def type @type end |
Class Method Details
.all_for(game) ⇒ Object
32 33 34 |
# File 'lib/gamefaqs/review.rb', line 32 def self.all_for(game) List.reviews(game) end |
.review_type(string) ⇒ Object
36 37 38 39 40 |
# File 'lib/gamefaqs/review.rb', line 36 def self.review_type(string) REVIEW_TYPES.each do |type| return type if string =~ /#{type}/i end end |
Instance Method Details
#created_at ⇒ Object
28 29 30 |
# File 'lib/gamefaqs/review.rb', line 28 def created_at @created_at ||= Date.parse(parse_review[:created_at], "%m/%d/%y") end |
#score_to_i ⇒ Object
18 19 20 21 22 |
# File 'lib/gamefaqs/review.rb', line 18 def score_to_i actual, max = @score.split("/") factor = 10 / max.to_i actual.to_i * factor end |
#text ⇒ Object
24 25 26 |
# File 'lib/gamefaqs/review.rb', line 24 def text @text ||= parse_review[:text] end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/gamefaqs/review.rb', line 14 def to_s "#{@game}: #{@score} by #{} (#{@title} [#{@type}])" end |