Class: Baron::Company

Inherits:
Object
  • Object
show all
Includes:
Shareholder
Defined in:
lib/baron/company.rb,
lib/baron/company/major_company.rb,
lib/baron/company/private_company.rb

Overview

A company represents one of the sets of railroad companies which exist in the game, including Private, Minor, and Major railroad companies

Direct Known Subclasses

MajorCompany, PrivateCompany

Defined Under Namespace

Classes: MajorCompany, PrivateCompany

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(abbreviation, name) ⇒ Company

Initialize the Company

Examples:

Baron::Company::MajorCompany.new('CPR', 'Canadian Pacific Railway')

Parameters:

  • abbreviation (String)
  • name (String)

34
35
36
37
# File 'lib/baron/company.rb', line 34

def initialize(abbreviation, name)
  @name = name
  @abbreviation = abbreviation
end

Instance Attribute Details

#abbreviationString (readonly)

The short abbreviation for the company

Examples:

company.abbreviation #=> 'LNWR'

Returns:

  • (String)

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

def abbreviation
  @abbreviation
end

#nameString (readonly)

The full name of the company

Examples:

company.abbreviation #=> 'London and North Western Railway'

Returns:

  • (String)

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

def name
  @name
end

Instance Method Details

#face_valueBaron::Money

The face value of this company

Most companies do not have a face value, but some types do and they should implement this and set the value to a non-nil value.

Examples:

company.face_value #=> nil

Returns:


60
61
# File 'lib/baron/company.rb', line 60

def face_value
end

#to_sString

Convert the company to a string containing their abbreviation

Examples:

company.to_s #=> 'CPR'

Returns:

  • (String)

46
47
48
# File 'lib/baron/company.rb', line 46

def to_s
  abbreviation
end