Class: Cinch::Plugins::Game
- Inherits:
-
Object
- Object
- Cinch::Plugins::Game
- Defined in:
- lib/cinch/plugins/bgg.rb
Constant Summary collapse
- NOT_RANKED_RANK =
10001
Instance Attribute Summary collapse
-
#categories ⇒ Object
Returns the value of attribute categories.
-
#designers ⇒ Object
Returns the value of attribute designers.
-
#id ⇒ Object
Returns the value of attribute id.
-
#maxplayers ⇒ Object
Returns the value of attribute maxplayers.
-
#mechanics ⇒ Object
Returns the value of attribute mechanics.
-
#minplayers ⇒ Object
Returns the value of attribute minplayers.
-
#name ⇒ Object
Returns the value of attribute name.
-
#playingtime ⇒ Object
Returns the value of attribute playingtime.
-
#publishers ⇒ Object
Returns the value of attribute publishers.
-
#rank ⇒ Object
Returns the value of attribute rank.
-
#rating ⇒ Object
Returns the value of attribute rating.
-
#year ⇒ Object
Returns the value of attribute year.
Instance Method Summary collapse
-
#game_rank ⇒ Object
Since we are resetting the not ranked values, let’s make sure we return the correct values.
-
#initialize(id, xml) ⇒ Game
constructor
A new instance of Game.
Constructor Details
#initialize(id, xml) ⇒ Game
Returns a new instance of Game.
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/cinch/plugins/bgg.rb', line 226 def initialize(id, xml) self.id = id self. = xml.css('statistics ratings average')[0]['value'].to_f self.rank = xml.css('statistics ratings ranks rank')[0]["value"] # if ranked, convert the value to integer; if not, set the value of the rank to the last possible self.rank = self.rank == "Not Ranked" ? NOT_RANKED_RANK : self.rank.to_i self.name = xml.css('name')[0]['value'] self.year = xml.css('yearpublished')[0]['value'].to_i self.minplayers = xml.css('minplayers')[0]['value'].to_i self.maxplayers = xml.css('maxplayers')[0]['value'].to_i self. = xml.css('playingtime')[0]['value'].to_i self.categories = xml.css('link[type=boardgamecategory]').map{ |l| l['value'] } self.mechanics = xml.css('link[type=boardgamemechanic]').map{ |l| l['value'] } self.designers = xml.css('link[type=boardgamedesigner]').map{ |l| l['value'] } self.publishers = xml.css('link[type=boardgamepublisher]').map{ |l| l['value'] } end |
Instance Attribute Details
#categories ⇒ Object
Returns the value of attribute categories.
222 223 224 |
# File 'lib/cinch/plugins/bgg.rb', line 222 def categories @categories end |
#designers ⇒ Object
Returns the value of attribute designers.
222 223 224 |
# File 'lib/cinch/plugins/bgg.rb', line 222 def designers @designers end |
#id ⇒ Object
Returns the value of attribute id.
222 223 224 |
# File 'lib/cinch/plugins/bgg.rb', line 222 def id @id end |
#maxplayers ⇒ Object
Returns the value of attribute maxplayers.
222 223 224 |
# File 'lib/cinch/plugins/bgg.rb', line 222 def maxplayers @maxplayers end |
#mechanics ⇒ Object
Returns the value of attribute mechanics.
222 223 224 |
# File 'lib/cinch/plugins/bgg.rb', line 222 def mechanics @mechanics end |
#minplayers ⇒ Object
Returns the value of attribute minplayers.
222 223 224 |
# File 'lib/cinch/plugins/bgg.rb', line 222 def minplayers @minplayers end |
#name ⇒ Object
Returns the value of attribute name.
222 223 224 |
# File 'lib/cinch/plugins/bgg.rb', line 222 def name @name end |
#playingtime ⇒ Object
Returns the value of attribute playingtime.
222 223 224 |
# File 'lib/cinch/plugins/bgg.rb', line 222 def @playingtime end |
#publishers ⇒ Object
Returns the value of attribute publishers.
222 223 224 |
# File 'lib/cinch/plugins/bgg.rb', line 222 def publishers @publishers end |
#rank ⇒ Object
Returns the value of attribute rank.
222 223 224 |
# File 'lib/cinch/plugins/bgg.rb', line 222 def rank @rank end |
#rating ⇒ Object
Returns the value of attribute rating.
222 223 224 |
# File 'lib/cinch/plugins/bgg.rb', line 222 def @rating end |
#year ⇒ Object
Returns the value of attribute year.
222 223 224 |
# File 'lib/cinch/plugins/bgg.rb', line 222 def year @year end |
Instance Method Details
#game_rank ⇒ Object
Since we are resetting the not ranked values, let’s make sure we return the correct values
245 246 247 |
# File 'lib/cinch/plugins/bgg.rb', line 245 def game_rank (self.rank == NOT_RANKED_RANK) ? "Not Ranked" : self.rank end |