class NdrImport::NonTabular::Line
This class behaves like a string and is used instead of the each source line of text. It allows us to contain additional information relating to the use of the line e.g. is the line within a record or for which fields the line has been used to capture a value.
Attributes
absolute_line_number[RW]
captured_fields[RW]
captures_values[RW]
in_a_record[RW]
record_line_number[RW]
removed[RW]
Public Class Methods
new(line, absolute_line_number)
click to toggle source
# File lib/ndr_import/non_tabular/line.rb, line 16 def initialize(line, absolute_line_number) @line = line.rstrip @absolute_line_number = absolute_line_number @in_a_record = false @removed = false @captured_fields = [] @captures_values = [] end
Public Instance Methods
=~(other)
click to toggle source
# File lib/ndr_import/non_tabular/line.rb, line 25 def =~(other) @line =~ other end
captured_for(field)
click to toggle source
# File lib/ndr_import/non_tabular/line.rb, line 37 def captured_for(field) @captured_fields << field if field && !@captured_fields.include?(field) end
match(*args)
click to toggle source
# File lib/ndr_import/non_tabular/line.rb, line 29 def match(*args) @line.match(*args) end
matches_for(field, value)
click to toggle source
# File lib/ndr_import/non_tabular/line.rb, line 41 def matches_for(field, value) @captures_values << [field, value] end
to_s()
click to toggle source
# File lib/ndr_import/non_tabular/line.rb, line 33 def to_s @line end