Class: Baron::Bank

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

Overview

The bank represents the source of money for turns and other financial aspects of the company. It can hold money, company shares (in the bank pool) trains, and more.

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(game) ⇒ Bank

Initialize the bank

Examples:

Baron::Bank.initialize(game)

Parameters:


25
26
27
# File 'lib/baron/bank.rb', line 25

def initialize(game)
  @game = game
end

Instance Attribute Details

#gameBaron::Game (readonly)

The game this bank belongs to

Examples:

bank.game

Returns:


16
17
18
# File 'lib/baron/bank.rb', line 16

def game
  @game
end

Instance Method Details

#cost(certificate) ⇒ Baron::Money

The cost of the certificate based on current market price

The cost of the certificate is the market price times the number of shares that the certificate is for.

Examples:

@bank.cost(certificate) #=> Baron::Money.new(68)

Parameters:

Returns:


40
41
42
# File 'lib/baron/bank.rb', line 40

def cost(certificate)
  certificate.market_cost(game.market)
end

#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 bank

Returns:

  • (String)

48
49
50
# File 'lib/baron/bank.rb', line 48

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