Class: GameFaqs::Game
- Inherits:
-
Object
- Object
- GameFaqs::Game
- Defined in:
- lib/gamefaqs/game.rb
Constant Summary collapse
- GENRES =
{ "Action" => "54", "Action-Adventure" => "163", "Adventure" => "50", "Driving" => "47", "Miscellaneous" => "49", "Role-Playing" => "48", "Simulation" => "46", "Sports" => "43", "Strategy" => "45"}
Instance Attribute Summary collapse
-
#codes ⇒ Object
readonly
Returns the value of attribute codes.
-
#faqs ⇒ Object
readonly
Returns the value of attribute faqs.
-
#homepage ⇒ Object
readonly
Returns the value of attribute homepage.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
Class Method Summary collapse
Instance Method Summary collapse
- #average_score(review_type = nil) ⇒ Object
- #average_score_to_s ⇒ Object
-
#initialize(name, platform, id) ⇒ Game
constructor
A new instance of Game.
- #questions ⇒ Object
- #reviews(review_type = nil) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, platform, id) ⇒ Game
Returns a new instance of Game.
8 9 10 11 12 13 |
# File 'lib/gamefaqs/game.rb', line 8 def initialize(name, platform, id) @name = name @platform = platform @id = id @homepage = "#{@platform.homepage}home/#{@id}.html" end |
Instance Attribute Details
#codes ⇒ Object (readonly)
Returns the value of attribute codes.
6 7 8 |
# File 'lib/gamefaqs/game.rb', line 6 def codes @codes end |
#faqs ⇒ Object (readonly)
Returns the value of attribute faqs.
6 7 8 |
# File 'lib/gamefaqs/game.rb', line 6 def faqs @faqs end |
#homepage ⇒ Object (readonly)
Returns the value of attribute homepage.
6 7 8 |
# File 'lib/gamefaqs/game.rb', line 6 def homepage @homepage end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/gamefaqs/game.rb', line 6 def name @name end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
6 7 8 |
# File 'lib/gamefaqs/game.rb', line 6 def platform @platform end |
Class Method Details
Instance Method Details
#average_score(review_type = nil) ⇒ Object
31 32 33 34 |
# File 'lib/gamefaqs/game.rb', line 31 def average_score(review_type=nil) sum = reviews(review_type).map{|r| r.score_to_i}.inject{|memo, score| memo + score} sum ? (sum / reviews(review_type).size.to_f) : -1 end |
#average_score_to_s ⇒ Object
36 37 38 |
# File 'lib/gamefaqs/game.rb', line 36 def average_score_to_s "%.2f - #{to_s}" % average_score end |
#questions ⇒ Object
27 28 29 |
# File 'lib/gamefaqs/game.rb', line 27 def questions List.questions(self) end |
#reviews(review_type = nil) ⇒ Object
23 24 25 |
# File 'lib/gamefaqs/game.rb', line 23 def reviews(review_type=nil) List.reviews(self, review_type) end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/gamefaqs/game.rb', line 19 def to_s "#{@name} [#{platform}]" end |