类 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) 点击切换源
调用超类方法
StringScanner::new
# File lib/csv/parser.rb, line 42 def initialize(*args) super @keeps = [] end
公共实例方法
each_line(row_separator) { |line| ... } 点击切换源
# File 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 lib/csv/parser.rb, line 65 def keep_back self.pos = @keeps.pop end
keep_drop() 点击切换源
# File lib/csv/parser.rb, line 69 def keep_drop @keeps.pop end
keep_end() 点击切换源
# File lib/csv/parser.rb, line 60 def keep_end start = @keeps.pop string.byteslice(start, pos - start) end
keep_start() 点击切换源
# File lib/csv/parser.rb, line 56 def keep_start @keeps.push(pos) end