Class: RockBooks::Account
- Inherits:
-
Struct
- Object
- Struct
- RockBooks::Account
- Defined in:
- lib/rock_books/types/account.rb
Overview
The ChartOfAccount holds the set of all these accounts for the entity.
Constant Summary collapse
- PERMITTED_CODE_CHAR_REGEX =
word chars (letters, numbers, underscores), hyphens, periods
/[\w\-\.]$/
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(code, type, name) ⇒ Account
constructor
A new instance of Account.
- #validate_code(code) ⇒ Object
Constructor Details
#initialize(code, type, name) ⇒ Account
Returns a new instance of Account.
14 15 16 17 |
# File 'lib/rock_books/types/account.rb', line 14 def initialize(code, type, name) validate_code(code) super end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code
4 5 6 |
# File 'lib/rock_books/types/account.rb', line 4 def code @code end |
#name ⇒ Object
Returns the value of attribute name
4 5 6 |
# File 'lib/rock_books/types/account.rb', line 4 def name @name end |
#type ⇒ Object
Returns the value of attribute type
4 5 6 |
# File 'lib/rock_books/types/account.rb', line 4 def type @type end |
Instance Method Details
#validate_code(code) ⇒ Object
8 9 10 11 12 |
# File 'lib/rock_books/types/account.rb', line 8 def validate_code(code) unless PERMITTED_CODE_CHAR_REGEX.match(code) raise "Code {#{code}} may only contain letters, numbers, underscores, hyphens, and periods." end end |