Class: Norma43::LineParsers::LineParser
- Inherits:
-
Object
- Object
- Norma43::LineParsers::LineParser
- Defined in:
- lib/norma43/line_parsers/line_parser.rb
Direct Known Subclasses
AccountEnd, AccountStart, AdditionalCurrency, AdditionalItem, DocumentEnd, DocumentStart, FileFormatValidator, Transaction
Instance Attribute Summary collapse
-
#line ⇒ Object
readonly
Returns the value of attribute line.
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(line) ⇒ LineParser
constructor
A new instance of LineParser.
Constructor Details
#initialize(line) ⇒ LineParser
Returns a new instance of LineParser.
7 8 9 |
# File 'lib/norma43/line_parsers/line_parser.rb', line 7 def initialize(line) @line = line end |
Instance Attribute Details
#line ⇒ Object (readonly)
Returns the value of attribute line.
6 7 8 |
# File 'lib/norma43/line_parsers/line_parser.rb', line 6 def line @line end |
Class Method Details
.field(name, range, type = :string) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/norma43/line_parsers/line_parser.rb', line 17 def self.field(name, range, type = :string) self.field_names.push name define_method name do if range.is_a?(Array) # let multivalued attribute range.map { |r| value_at_position(r, type) }.compact else value_at_position range, type end end end |
Instance Method Details
#attributes ⇒ Object
11 12 13 14 15 |
# File 'lib/norma43/line_parsers/line_parser.rb', line 11 def attributes self.class.field_names.each_with_object({}) do |field, attrs| attrs[field] = self.public_send(field) end end |