Class: RockBooks::AccountType
- Inherits:
-
Struct
- Object
- Struct
- RockBooks::AccountType
- Defined in:
- lib/rock_books/types/account_type.rb
Constant Summary collapse
- ASSET =
self.new(:asset, 'Asset', 'Assets')
- LIABILITY =
self.new(:liability, 'Liability', 'Liabilities')
- EQUITY =
self.new(:equity, 'Equity', 'Equity')
- INCOME =
self.new(:income, 'Income', 'Income')
- EXPENSE =
self.new(:expense, 'Expense', 'Expenses')
- ALL_TYPES =
[ASSET, LIABILITY, EQUITY, INCOME, EXPENSE]
- LETTER_TO_TYPE =
{ 'A' => ASSET, 'L' => LIABILITY, 'O' => EQUITY, 'I' => INCOME, 'E' => EXPENSE }
- SYMBOL_TO_TYPE =
{ :asset => ASSET, :liability => LIABILITY, :equity => EQUITY, :income => INCOME, :expense => EXPENSE }
Instance Attribute Summary collapse
-
#plural_name ⇒ Object
Returns the value of attribute plural_name.
-
#singular_name ⇒ Object
Returns the value of attribute singular_name.
-
#symbol ⇒ Object
Returns the value of attribute symbol.
Class Method Summary collapse
-
.letter_to_type(string) ⇒ Object
Converts type upper case letter representation to a type object (e.g. ‘A’ => ASSET).
- .symbol_to_type(symbol) ⇒ Object
Instance Attribute Details
#plural_name ⇒ Object
Returns the value of attribute plural_name
5 6 7 |
# File 'lib/rock_books/types/account_type.rb', line 5 def plural_name @plural_name end |
#singular_name ⇒ Object
Returns the value of attribute singular_name
5 6 7 |
# File 'lib/rock_books/types/account_type.rb', line 5 def singular_name @singular_name end |
#symbol ⇒ Object
Returns the value of attribute symbol
5 6 7 |
# File 'lib/rock_books/types/account_type.rb', line 5 def symbol @symbol end |
Class Method Details
.letter_to_type(string) ⇒ Object
Converts type upper case letter representation to a type object (e.g. ‘A’ => ASSET)
32 33 34 35 36 37 38 |
# File 'lib/rock_books/types/account_type.rb', line 32 def self.letter_to_type(string) key = string[0].upcase LETTER_TO_TYPE.fetch(key) do raise Error.new("Account type of #{string} not valid. " + "Must be one of #{LETTER_TO_TYPE.keys} (#{ALL_TYPES.map(&:singular_name)})") end end |
.symbol_to_type(symbol) ⇒ Object
40 41 42 |
# File 'lib/rock_books/types/account_type.rb', line 40 def self.symbol_to_type(symbol) SYMBOL_TO_TYPE[symbol] end |