Class: RockBooks::Account

Inherits:
Struct
  • Object
show all
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

Instance Method Summary collapse

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

#codeObject

Returns the value of attribute code

Returns:

  • (Object)

    the current value of code



4
5
6
# File 'lib/rock_books/types/account.rb', line 4

def code
  @code
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



4
5
6
# File 'lib/rock_books/types/account.rb', line 4

def name
  @name
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of 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