Class: Sped2DB::Layout
- Inherits:
-
Object
- Object
- Sped2DB::Layout
- Defined in:
- lib/sped2db/layout.rb
Constant Summary collapse
- VERSIONS =
{ fiscal: %w[009 010 011], contrib: %w[002 003] }.freeze
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(type, version) ⇒ Layout
constructor
A new instance of Layout.
- #to_s ⇒ Object
Constructor Details
#initialize(type, version) ⇒ Layout
Returns a new instance of Layout.
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
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/sped2db/layout.rb', line 8 def type @type end |
#version ⇒ Object (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_s ⇒ Object
28 29 30 |
# File 'lib/sped2db/layout.rb', line 28 def to_s "SPED #{type.to_s.capitalize} v#{version}" end |