Class: Baron::Player

Inherits:
Object
  • Object
show all
Includes:
Shareholder
Defined in:
lib/baron/player.rb

Overview

A partipant in a game

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Shareholder

#add_transaction, #balance, #certificates, #certificates_for, #directorships, #give, #grant, #largest_train, #percentage_owned, #private_certificates, #trains

Constructor Details

#initialize(name) ⇒ Player

Returns a new instance of Player.

Examples:

Baron::Player::Shareholder.new('Bob')

Parameters:

  • name (String)

    The player's name

See Also:

  • description

33
34
35
# File 'lib/baron/player.rb', line 33

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameString (readonly)

The player's name

Examples:

shareholder = Baron::Player::Shareholder.new('Bob')
shareholder.name #=> 'Bob'

Returns:

  • (String)

15
16
17
# File 'lib/baron/player.rb', line 15

def name
  @name
end

#positionFixnum (readonly)

The player's position in the game

Examples:

shareholder.position #=> 5

Returns:

  • (Fixnum)

    The player's seating position in the game.


24
25
26
# File 'lib/baron/player.rb', line 24

def position
  @position
end

Instance Method Details

#inspectString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return a string representation of the player

Returns:

  • (String)

52
53
54
# File 'lib/baron/player.rb', line 52

def inspect
  "#<Baron::Player:#{object_id} #{self}>"
end

#to_sString

Convert the player object to a string

Examples:

Baron::Player::Shareholder.new('Bob').to_s #=> 'Bob'

Returns:

  • (String)

    The player's name


44
45
46
# File 'lib/baron/player.rb', line 44

def to_s
  name
end