Class: JustGo::Stone
- Inherits:
-
Object
- Object
- JustGo::Stone
- Defined in:
- lib/just_go/stone.rb
Overview
Stone
A stone that is placed on the board.
Instance Attribute Summary collapse
-
#chain_id ⇒ Object
readonly
Returns the value of attribute chain_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#player_number ⇒ Object
readonly
Returns the value of attribute player_number.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(id:, player_number:, chain_id: nil) ⇒ Stone
constructor
A new instance of Stone.
- #join_chain(stone) ⇒ Object
Constructor Details
#initialize(id:, player_number:, chain_id: nil) ⇒ Stone
Returns a new instance of Stone.
7 8 9 10 11 |
# File 'lib/just_go/stone.rb', line 7 def initialize(id: , player_number: , chain_id: nil) @id = id @player_number = player_number @chain_id = chain_id end |
Instance Attribute Details
#chain_id ⇒ Object (readonly)
Returns the value of attribute chain_id.
15 16 17 |
# File 'lib/just_go/stone.rb', line 15 def chain_id @chain_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
13 14 15 |
# File 'lib/just_go/stone.rb', line 13 def id @id end |
#player_number ⇒ Object (readonly)
Returns the value of attribute player_number.
14 15 16 |
# File 'lib/just_go/stone.rb', line 14 def player_number @player_number end |
Instance Method Details
#as_json ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/just_go/stone.rb', line 17 def as_json { id: id, player_number: player_number, chain_id: chain_id } end |
#join_chain(stone) ⇒ Object
25 26 27 |
# File 'lib/just_go/stone.rb', line 25 def join_chain(stone) @chain_id = stone.chain_id end |