Class: DTAUS::Erweiterung
- Inherits:
-
Object
- Object
- DTAUS::Erweiterung
- Defined in:
- lib/dtaus/erweiterung.rb
Overview
Eine Erweiterung eines C-Segments Stellt eine Länge von 27 Zeichen sicher
Defined Under Namespace
Classes: IncorrectErweiterungType
Constant Summary collapse
- TYPE_KUNDE =
'01'
- TYPE_VERWENDUNGZWECK =
'02'
- TYPE_AUFTRAGGEBER =
'03'
- TYPES =
{ :kunde => TYPE_KUNDE, :verwendungszweck => TYPE_VERWENDUNGZWECK, :auftraggeber => TYPE_AUFTRAGGEBER }
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.from_string(_typ, _text) ⇒ Object
Erstellt ein Array von Erweiterungen aus einem beliebig langem String.
Instance Method Summary collapse
-
#initialize(_type, _text) ⇒ Erweiterung
constructor
erweiterung = Erweiterung.new(:verwendungszweck, ‘Rechnung Nr 12345’) _type muss ein Symbol aus :kunde, :verwendungszweck, :auftraggeber sein.
- #to_dta ⇒ Object
Constructor Details
#initialize(_type, _text) ⇒ Erweiterung
erweiterung = Erweiterung.new(:verwendungszweck, ‘Rechnung Nr 12345’) _type muss ein Symbol aus :kunde, :verwendungszweck, :auftraggeber sein.
36 37 38 39 40 41 |
# File 'lib/dtaus/erweiterung.rb', line 36 def initialize(_type, _text) raise IncorrectErweiterungType.new unless TYPES.keys.include?(_type) or TYPES.values.include?(_type) @text = DTAUS.convert_text(_text).ljust(27) raise IncorrectSize.new("Text size may not exceed 27 Chars") if text.size > 27 @type = TYPES[_type] || _type end |
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
17 18 19 |
# File 'lib/dtaus/erweiterung.rb', line 17 def text @text end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
17 18 19 |
# File 'lib/dtaus/erweiterung.rb', line 17 def type @type end |
Class Method Details
.from_string(_typ, _text) ⇒ Object
Erstellt ein Array von Erweiterungen aus einem beliebig langem String
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dtaus/erweiterung.rb', line 21 def self.from_string(_typ, _text) erweiterungen = [] _text = DTAUS.convert_text(_text) if _text.size > 27 index = 27 while index < _text.size erweiterungen << Erweiterung.new(_typ, _text[index..index += 26]) end end erweiterungen end |
Instance Method Details
#to_dta ⇒ Object
43 44 45 |
# File 'lib/dtaus/erweiterung.rb', line 43 def to_dta "#{type}#{text}" end |