Class: Baron::InitialOffering

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

Overview

The initial offering is where company certificates, and trains are held until they are purchased by a player or corporation.

Note: Many games treat things held in the initial offering differently than things held in the bank pool for the purposes of pricing, dividend payouts and more.

Defined Under Namespace

Classes: ParPriceAlreadySet

Instance Method Summary collapse

Methods included from Shareholder

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

Instance Method Details

#cost(certificate) ⇒ Baron::Money

Returns the cost of the certificate

This will be determined by its face value or par price.

Examples:

initial_offering.cost(certificate) #=> $100

Parameters:

Returns:


22
23
24
25
# File 'lib/baron/initial_offering.rb', line 22

def cost(certificate)
  company = certificate.company
  company.face_value || get_par_price(company) * certificate.num_shares
end

#get_par_price(company) ⇒ Baron::Money

Set the par price for a major company

Examples:

initial_offering.get_par_price(company) #=> Baron::Money.new(100)

Parameters:

Returns:


35
36
37
38
# File 'lib/baron/initial_offering.rb', line 35

def get_par_price(company)
  @par_prices ||= {}
  @par_prices[company]
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 initial offering

Returns:

  • (String)

61
62
63
# File 'lib/baron/initial_offering.rb', line 61

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

#set_par_price(company, par_price) ⇒ void

This method returns an undefined value.

Set the par price for a major company

Examples:

initial_offering.set_par_price(company, Baron::Money.new(100))

Parameters:


49
50
51
52
53
54
55
# File 'lib/baron/initial_offering.rb', line 49

def set_par_price(company, par_price)
  fail(
    ParPriceAlreadySet,
    "Attempted to reset par price for #{company}"
  ) if get_par_price(company)
  @par_prices[company] = par_price
end