CSV::Scanner receives a CSV
output, scans it and return the content. It also controls the life cycle of the object with its methods keep_start
, keep_end
, keep_back
, keep_drop
.
Uses StringScanner
(the official strscan gem). Strscan provides lexical scanning operations on a String
. We inherit its object and take advantage on the methods. For more information, please visit: ruby-doc.org/stdlib-2.6.1/libdoc/strscan/rdoc/StringScanner.html
# File ruby-3.1.2/lib/csv/parser.rb, line 48 def each_line(row_separator) position = pos rest.each_line(row_separator) do |line| position += line.bytesize self.pos = position yield(line) end end
# File ruby-3.1.2/lib/csv/parser.rb, line 66 def keep_back self.pos = @keeps.pop end
# File ruby-3.1.2/lib/csv/parser.rb, line 70 def keep_drop @keeps.pop end