Class: Sped2DB::Layout

Inherits:
Object
  • Object
show all
Defined in:
lib/sped2db/layout.rb

Constant Summary collapse

VERSIONS =
{
  fiscal: %w[009 010 011],
  contrib: %w[002 003]
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, version) ⇒ Layout

Returns a new instance of Layout.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/sped2db/layout.rb', line 10

def initialize(type, version)
  raise ArgumentError, 'type is nil' if type.nil?
  type = type.to_sym

  layouts = VERSIONS.keys.join(', ')
  raise ArgumentError, "type must be one of #{layouts}" unless
    VERSIONS.key? type

  raise ArgumentError, 'version is nil' if version.nil?

  versions = VERSIONS[type].join(', ')
  raise ArgumentError, "version must be one of #{versions}" unless
    versions.include? version

  @type = type
  @version = version
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/sped2db/layout.rb', line 8

def type
  @type
end

#versionObject (readonly)

Returns the value of attribute version.



8
9
10
# File 'lib/sped2db/layout.rb', line 8

def version
  @version
end

Instance Method Details

#to_sObject



28
29
30
# File 'lib/sped2db/layout.rb', line 28

def to_s
  "SPED #{type.to_s.capitalize} v#{version}"
end