Class: CSV::Parser (Ruby 2.7.5)
Description: Class : CSV::Parser - Ruby 2.7.5

### Home Classes Methods

### In Files

- csv/parser.rb

### Parent

Object

### Namespace

- CLASS CSV::Parser::InputsScanner
- CLASS CSV::Parser::InvalidEncoding
- CLASS CSV::Parser::Scanner
- CLASS CSV::Parser::UnoptimizedStringIO

### Methods

- ::new
- #column_separator
- #field_size_limit
- #header_row?
- #headers
- #liberal_parsing?
- #line
- #lineno
- #parse
- #quote_character
- #return_headers?
- #row_separator
- #skip_blanks?
- #skip_lines
- #unconverted_fields?
- #use_headers?

### 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

Note: Don't use this class directly. This is an internal class.

### Constants

SCANNER_TEST

### Public Class Methods

new(input, options) click to toggle source

                   # File csv/parser.rb, line 258
    def initialize(input, options)
      @input = input
      @options = options
      @samples = []

      prepare
    end

### Public Instance Methods

column_separator() click to toggle source

                   # File csv/parser.rb, line 266
    def column_separator
      @column_separator
    end

field_size_limit() click to toggle source

                   # File csv/parser.rb, line 278
    def field_size_limit
      @field_size_limit
    end

header_row?() click to toggle source

                   # File csv/parser.rb, line 294
    def header_row?
      @use_headers and @headers.nil?
    end

headers() click to toggle source

                   # File csv/parser.rb, line 290
    def headers
      @headers
    end

liberal_parsing?() click to toggle source

                   # File csv/parser.rb, line 306
    def liberal_parsing?
      @liberal_parsing
    end

line() click to toggle source

                   # File csv/parser.rb, line 314
    def line
      last_line
    end

lineno() click to toggle source

                   # File csv/parser.rb, line 310
    def lineno
      @lineno
    end

parse(&block) click to toggle source

                   # File csv/parser.rb, line 318
    def parse(&block)
      return to_enum(__method__) unless block_given?

      if @return_headers and @headers and @raw_headers
        headers = Row.new(@headers, @raw_headers, true)
        if @unconverted_fields
          headers = add_unconverted_fields(headers, [])
        end
        yield headers
      end

      begin
        @scanner ||= build_scanner
        if quote_character.nil?
          parse_no_quote(&block)
        elsif @need_robust_parsing
          parse_quotable_robust(&block)
        else
          parse_quotable_loose(&block)
        end
      rescue InvalidEncoding
        if @scanner
          ignore_broken_line
          lineno = @lineno
        else
          lineno = @lineno + 1
        end
        message = "Invalid byte sequence in #{@encoding}"
        raise MalformedCSVError.new(message, lineno)
      end
    end

quote_character() click to toggle source

                   # File csv/parser.rb, line 274
    def quote_character
      @quote_character
    end

return_headers?() click to toggle source

                   # File csv/parser.rb, line 298
    def return_headers?
      @return_headers
    end

row_separator() click to toggle source

                   # File csv/parser.rb, line 270
    def row_separator
      @row_separator
    end

skip_blanks?() click to toggle source

                   # File csv/parser.rb, line 302
    def skip_blanks?
      @skip_blanks
    end

skip_lines() click to toggle source

                   # File csv/parser.rb, line 282
    def skip_lines
      @skip_lines
    end

unconverted_fields?() click to toggle source

                   # File csv/parser.rb, line 286
    def unconverted_fields?
      @unconverted_fields
    end

use_headers?() click to toggle source

                   # File csv/parser.rb, line 350
    def use_headers?
      @use_headers
    end