Class: Portal2Item
- Inherits:
-
Object
- Object
- Portal2Item
- Includes:
- GameItem
- Defined in:
- lib/steam/community/portal2/portal2_item.rb
Overview
Represents a Portal 2 item
Constant Summary collapse
- BOTS =
The names of the bots available in Portal 2
[ :pbody, :atlas ]
Instance Attribute Summary
Attributes included from GameItem
#attributes, #backpack_position, #class, #count, #defindex, #id, #level, #name, #quality, #slot, #type
Instance Method Summary collapse
-
#bots_equipped? ⇒ Array<String>
Returns the symbols for each bot this player has equipped this item.
-
#equipped? ⇒ Boolean
Returns whether this item is equipped by this player at all.
-
#initialize(inventory, item_data) ⇒ Portal2Item
constructor
Creates a new instance of a Portal 2 item with the given data.
Methods included from GameItem
Constructor Details
#initialize(inventory, item_data) ⇒ Portal2Item
Creates a new instance of a Portal 2 item with the given data
23 24 25 26 27 28 29 30 |
# File 'lib/steam/community/portal2/portal2_item.rb', line 23 def initialize(inventory, item_data) super @equipped = {} BOTS.each_index do |class_id| @equipped[BOTS[class_id]] = (item_data[:inventory] & (1 << 16 + class_id) != 0) end end |
Instance Method Details
#bots_equipped? ⇒ Array<String>
Returns the symbols for each bot this player has equipped this item
36 37 38 |
# File 'lib/steam/community/portal2/portal2_item.rb', line 36 def bots_equipped? @equipped.reject { |bot_id, equipped| !equipped } end |
#equipped? ⇒ Boolean
Returns whether this item is equipped by this player at all
43 44 45 |
# File 'lib/steam/community/portal2/portal2_item.rb', line 43 def equipped? @equipped.has_value? true end |