Class: Reading::Line
Overview
A bridge between rows as strings and as parsable Rows, used whenever the context of the line in the CSV is needed, e.g. converting a line to a Row, or adding a CSV line to a Row parsing error.
Instance Attribute Summary collapse
-
#csv ⇒ Object
readonly
Returns the value of attribute csv.
-
#string ⇒ Object
readonly
Returns the value of attribute string.
Instance Method Summary collapse
-
#initialize(string, csv) ⇒ Line
constructor
A new instance of Line.
- #to_row ⇒ Object
Constructor Details
#initialize(string, csv) ⇒ Line
Returns a new instance of Line.
12 13 14 15 |
# File 'lib/reading/line.rb', line 12 def initialize(string, csv) @string = string.dup.force_encoding(Encoding::UTF_8).strip @csv = csv end |
Instance Attribute Details
#csv ⇒ Object (readonly)
Returns the value of attribute csv.
10 11 12 |
# File 'lib/reading/line.rb', line 10 def csv @csv end |
#string ⇒ Object (readonly)
Returns the value of attribute string.
10 11 12 |
# File 'lib/reading/line.rb', line 10 def string @string end |
Instance Method Details
#to_row ⇒ Object
17 18 19 20 21 |
# File 'lib/reading/line.rb', line 17 def to_row return CompactPlannedRow.new(self) if CompactPlannedRow.match?(self) return BlankRow.new(self) if BlankRow.match?(self) RegularRow.new(self) end |