Class: CSV::Parser::Scanner (Ruby 2.7.3)
Description: Class : CSV::Parser::Scanner - Ruby 2.7.3

### Home Classes Methods

### In Files

- csv/parser.rb

### Parent

StringScanner

### Methods

- ::new
- #each_line
- #keep_back
- #keep_drop
- #keep_end
- #keep_start

### Class/Module Index

Quicksearch

- CSV
- CSV::DeleteSuffix
- CSV::FieldsConverter
- CSV::MalformedCSVError
- CSV::MatchP
- CSV::Parser
- CSV::Parser::InputsScanner
- CSV::Parser::InvalidEncoding
- CSV::Parser::Scanner
- CSV::Parser::UnoptimizedStringIO
- CSV::Row
- CSV::Table
- CSV::Writer
- Object

No matching classes.

# CSV::Parser::Scanner

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

### Public Class Methods

new(*args) click to toggle source

                   # File csv/parser.rb, line 42
    def initialize(*args)
      super
      @keeps = []
    end

### Public Instance Methods

each_line(row_separator) click to toggle source

                   # File 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() click to toggle source

                   # File csv/parser.rb, line 65
    def keep_back
      self.pos = @keeps.pop
    end

keep_drop() click to toggle source

                   # File csv/parser.rb, line 69
    def keep_drop
      @keeps.pop
    end

keep_end() click to toggle source

                   # File csv/parser.rb, line 60
    def keep_end
      start = @keeps.pop
      string.byteslice(start, pos - start)
    end

keep_start() click to toggle source

                   # File csv/parser.rb, line 56
    def keep_start
      @keeps.push(pos)
    end