Class: CSV::Parser::Scanner
- Inherits:
-
StringScanner
- Object
- StringScanner
- CSV::Parser::Scanner
- Defined in:
- lib/csv/parser.rb
Instance Method Summary collapse
- #each_line(row_separator) ⇒ Object
-
#initialize(*args) ⇒ Scanner
constructor
A new instance of Scanner.
- #keep_back ⇒ Object
- #keep_drop ⇒ Object
- #keep_end ⇒ Object
- #keep_start ⇒ Object
Constructor Details
#initialize(*args) ⇒ Scanner
Returns a new instance of Scanner.
21 22 23 24 |
# File 'lib/csv/parser.rb', line 21 def initialize(*args) super @keeps = [] end |
Instance Method Details
#each_line(row_separator) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/csv/parser.rb', line 26 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 ⇒ Object
44 45 46 |
# File 'lib/csv/parser.rb', line 44 def keep_back self.pos = @keeps.pop end |
#keep_drop ⇒ Object
48 49 50 |
# File 'lib/csv/parser.rb', line 48 def keep_drop @keeps.pop end |
#keep_end ⇒ Object
39 40 41 42 |
# File 'lib/csv/parser.rb', line 39 def keep_end start = @keeps.pop string[start, pos - start] end |
#keep_start ⇒ Object
35 36 37 |
# File 'lib/csv/parser.rb', line 35 def keep_start @keeps.push(pos) end |