Class: Cinch::Plugins::User
- Inherits:
-
Object
- Object
- Cinch::Plugins::User
- Defined in:
- lib/cinch/plugins/bgg.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
Returns the value of attribute collection.
-
#hot_games ⇒ Object
Returns the value of attribute hot_games.
-
#name ⇒ Object
Returns the value of attribute name.
-
#top_games ⇒ Object
Returns the value of attribute top_games.
Instance Method Summary collapse
-
#initialize(username, user_xml, collection_xml) ⇒ User
constructor
A new instance of User.
- #owned ⇒ Object
- #played ⇒ Object
- #rated ⇒ Object
- #trading ⇒ Object
- #wanted ⇒ Object
Constructor Details
#initialize(username, user_xml, collection_xml) ⇒ User
Returns a new instance of User.
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/cinch/plugins/bgg.rb', line 254 def initialize(username, user_xml, collection_xml) self.name = username self.top_games = user_xml.css("top item").map{ |g| g["name"] } self.hot_games = user_xml.css("hot item").map{ |g| g["name"] } self.collection = {} collection_xml.css("items item").each do |g| self.collection[g["objectid"]] = {} self.collection[g["objectid"]]["name"] = g.css("name")[0].content self.collection[g["objectid"]]["own"] = g.css("status")[0]['own'].to_i self.collection[g["objectid"]]["for_trade"] = g.css("status")[0]['fortrade'].to_i self.collection[g["objectid"]]["want"] = g.css("status")[0]['want'].to_i self.collection[g["objectid"]]["plays"] = g.css("numplays")[0].content.to_i self.collection[g["objectid"]]["rating"] = g.css("stats")[0].css("rating")[0]['value'] end end |
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
252 253 254 |
# File 'lib/cinch/plugins/bgg.rb', line 252 def collection @collection end |
#hot_games ⇒ Object
Returns the value of attribute hot_games.
252 253 254 |
# File 'lib/cinch/plugins/bgg.rb', line 252 def hot_games @hot_games end |
#name ⇒ Object
Returns the value of attribute name.
252 253 254 |
# File 'lib/cinch/plugins/bgg.rb', line 252 def name @name end |
#top_games ⇒ Object
Returns the value of attribute top_games.
252 253 254 |
# File 'lib/cinch/plugins/bgg.rb', line 252 def top_games @top_games end |
Instance Method Details
#owned ⇒ Object
270 271 272 |
# File 'lib/cinch/plugins/bgg.rb', line 270 def owned self.collection.select{ |id, game| game["own"] == 1 } end |
#played ⇒ Object
286 287 288 |
# File 'lib/cinch/plugins/bgg.rb', line 286 def played self.collection.select{ |id, game| game["plays"] > 0 } end |
#rated ⇒ Object
282 283 284 |
# File 'lib/cinch/plugins/bgg.rb', line 282 def rated self.collection.reject{ |id, game| game["rating"] == "N/A" } end |
#trading ⇒ Object
274 275 276 |
# File 'lib/cinch/plugins/bgg.rb', line 274 def trading self.collection.select{ |id, game| game["for_trade"] == 1 } end |
#wanted ⇒ Object
278 279 280 |
# File 'lib/cinch/plugins/bgg.rb', line 278 def wanted self.collection.select{ |id, game| game["want"] == 1 } end |