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]
- TYPE_HASH =
{ 'A' => ASSET, 'L' => LIABILITY, 'O' => EQUITY, 'I' => INCOME, 'E' => 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
-
.to_type(string) ⇒ Object
Converts strings.
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
.to_type(string) ⇒ Object
Converts strings
24 25 26 27 28 29 30 31 |
# File 'lib/rock_books/types/account_type.rb', line 24 def self.to_type(string) type = TYPE_HASH[string[0].upcase] if type.nil? raise Error.new("Account type of #{string} not valid. " + "Must be one of #{TYPE_HASH.keys} (#{ALL_TYPES.map(&:singular_name)})") end type end |