Class: NdrImport::NonTabular::Line
- Inherits:
-
Object
- Object
- NdrImport::NonTabular::Line
- Defined in:
- lib/ndr_import/non_tabular/line.rb
Overview
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.
Instance Attribute Summary collapse
-
#absolute_line_number ⇒ Object
Returns the value of attribute absolute_line_number.
-
#captured_fields ⇒ Object
Returns the value of attribute captured_fields.
-
#captures_values ⇒ Object
Returns the value of attribute captures_values.
-
#in_a_record ⇒ Object
Returns the value of attribute in_a_record.
-
#record_line_number ⇒ Object
Returns the value of attribute record_line_number.
-
#removed ⇒ Object
Returns the value of attribute removed.
Instance Method Summary collapse
- #=~(other) ⇒ Object
- #captured_for(field) ⇒ Object
-
#initialize(line, absolute_line_number) ⇒ Line
constructor
A new instance of Line.
- #match(*args) ⇒ Object
- #matches_for(field, value) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(line, absolute_line_number) ⇒ Line
Returns a new instance of Line.
16 17 18 19 20 21 22 23 |
# 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 |
Instance Attribute Details
#absolute_line_number ⇒ Object
Returns the value of attribute absolute_line_number.
9 10 11 |
# File 'lib/ndr_import/non_tabular/line.rb', line 9 def absolute_line_number @absolute_line_number end |
#captured_fields ⇒ Object
Returns the value of attribute captured_fields.
9 10 11 |
# File 'lib/ndr_import/non_tabular/line.rb', line 9 def captured_fields @captured_fields end |
#captures_values ⇒ Object
Returns the value of attribute captures_values.
9 10 11 |
# File 'lib/ndr_import/non_tabular/line.rb', line 9 def captures_values @captures_values end |
#in_a_record ⇒ Object
Returns the value of attribute in_a_record.
9 10 11 |
# File 'lib/ndr_import/non_tabular/line.rb', line 9 def in_a_record @in_a_record end |
#record_line_number ⇒ Object
Returns the value of attribute record_line_number.
9 10 11 |
# File 'lib/ndr_import/non_tabular/line.rb', line 9 def record_line_number @record_line_number end |
#removed ⇒ Object
Returns the value of attribute removed.
9 10 11 |
# File 'lib/ndr_import/non_tabular/line.rb', line 9 def removed @removed end |
Instance Method Details
#=~(other) ⇒ Object
25 26 27 |
# File 'lib/ndr_import/non_tabular/line.rb', line 25 def =~(other) @line =~ other end |
#captured_for(field) ⇒ Object
37 38 39 |
# 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) ⇒ Object
29 30 31 |
# File 'lib/ndr_import/non_tabular/line.rb', line 29 def match(*args) @line.match(*args) end |
#matches_for(field, value) ⇒ Object
41 42 43 |
# File 'lib/ndr_import/non_tabular/line.rb', line 41 def matches_for(field, value) @captures_values << [field, value] end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/ndr_import/non_tabular/line.rb', line 33 def to_s @line end |