Class: BoardgameEngine::Player

Inherits:
Object
  • Object
show all
Defined in:
lib/boardgame_engine/boardgame.rb

Overview

Class representing a player in a game

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Player

Creates a player object with the given name

Parameters:

  • name (String)

    the name of the player



13
14
15
# File 'lib/boardgame_engine/boardgame.rb', line 13

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/boardgame_engine/boardgame.rb', line 8

def name
  @name
end

Instance Method Details

#to_sString

String representation of player

Returns:

  • (String)

    the name of the player



20
21
22
# File 'lib/boardgame_engine/boardgame.rb', line 20

def to_s
  @name.to_s
end