class CSV::Parser::Scanner
CSV::Scanner 接收 CSV
输出,扫描它并返回内容。它还通过其方法 keep_start
、keep_end
、keep_back
、keep_drop
控制对象的生命周期。
使用 StringScanner(官方 strscan gem)。Strscan 提供对 String
的词法扫描操作。我们继承它的对象并利用其方法。更多信息,请访问:ruby-doc.org/stdlib-2.6.1/libdoc/strscan/rdoc/StringScanner.html
公共类方法
new(*args) 点击以切换源代码
调用父类方法
# File csv-3.3.2/lib/csv/parser.rb, line 42 def initialize(*args) super @keeps = [] end
公共实例方法
each_line(row_separator) { |line| ... } 点击以切换源代码
# File csv-3.3.2/lib/csv/parser.rb, line 47 def each_line(row_separator) position = pos rest.each_line(row_separator) do |line| position += line.bytesize self.pos = position yield(line) end end
keep_back() 点击以切换源代码
# File csv-3.3.2/lib/csv/parser.rb, line 65 def keep_back self.pos = @keeps.pop end
keep_drop() 点击以切换源代码
# File csv-3.3.2/lib/csv/parser.rb, line 69 def keep_drop @keeps.pop end
keep_end() 点击以切换源代码
# File csv-3.3.2/lib/csv/parser.rb, line 60 def keep_end start = @keeps.pop string.byteslice(start, pos - start) end
keep_start() 点击以切换源代码
# File csv-3.3.2/lib/csv/parser.rb, line 56 def keep_start @keeps.push(pos) end