Class: Beefdump::Game::State
- Inherits:
-
Object
- Object
- Beefdump::Game::State
- Defined in:
- lib/beefdump/game/state.rb
Instance Attribute Summary collapse
-
#game ⇒ Object
readonly
Returns the value of attribute game.
-
#players ⇒ Object
readonly
Returns the value of attribute players.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(players) ⇒ State
constructor
A new instance of State.
Constructor Details
#initialize(players) ⇒ State
Returns a new instance of State.
7 8 9 |
# File 'lib/beefdump/game/state.rb', line 7 def initialize(players) @players = players end |
Instance Attribute Details
#game ⇒ Object (readonly)
Returns the value of attribute game.
5 6 7 |
# File 'lib/beefdump/game/state.rb', line 5 def game @game end |
#players ⇒ Object (readonly)
Returns the value of attribute players.
5 6 7 |
# File 'lib/beefdump/game/state.rb', line 5 def players @players end |
Class Method Details
.from_xml(xml, game) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/beefdump/game/state.rb', line 11 def self.from_xml(xml, game) players = [] xml['players'].first['player'].each do |player| position = player['position'].first players << Game::Player.new(player['name'], OpenStruct.new({:x => position['x'].to_i, :y => position['y'].to_i})) end self.new(players) end |