Class: TotalIn::LineParser
- Inherits:
-
Object
- Object
- TotalIn::LineParser
- Defined in:
- lib/total_in/line_parser.rb
Direct Known Subclasses
FileFormatValidator, TotalIn::LineParsers::AccountEnd, TotalIn::LineParsers::AccountStart, TotalIn::LineParsers::DeductionStart, TotalIn::LineParsers::DocumentEnd, TotalIn::LineParsers::DocumentStart, TotalIn::LineParsers::International, TotalIn::LineParsers::Locality, TotalIn::LineParsers::PaymentStart, TotalIn::LineParsers::SenderAccount, TotalIn::LineParsers::Values
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.
6 7 8 |
# File 'lib/total_in/line_parser.rb', line 6 def initialize line @line = line end |
Instance Attribute Details
#line ⇒ Object (readonly)
Returns the value of attribute line.
5 6 7 |
# File 'lib/total_in/line_parser.rb', line 5 def line @line end |
Class Method Details
.field(name, range, type = :string) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/total_in/line_parser.rb', line 16 def self.field name, range, type = :string self.field_names.push name define_method name do if range.is_a?(Array) range.map { |r| value_at_position(r, type) }.compact else value_at_position range, type end end end |
Instance Method Details
#attributes ⇒ Object
10 11 12 13 14 |
# File 'lib/total_in/line_parser.rb', line 10 def attributes self.class.field_names.each_with_object({}) do |field, attrs| attrs[field] = self.public_send(field) end end |