class CSV::Parser
Note: Don’t use this class directly. This is an internal class.
Constants
- ARGF_OBJECT_ID
- SCANNER_TEST
- SCANNER_TEST_CHUNK_SIZE_NAME
- SCANNER_TEST_CHUNK_SIZE_VALUE
- STRING_SCANNER_SCAN_ACCEPT_STRING
Public Class Methods
Source
# File lib/csv/parser.rb, line 25 def eof?(input) # We can't use input != ARGF in Ractor. Because ARGF isn't a # shareable object. input.object_id != ARGF_OBJECT_ID and input.respond_to?(:eof) and input.eof? end
Convenient method to check whether the give input reached EOF or not.
Source
# File lib/csv/parser.rb, line 348 def initialize(input, options) @input = input @options = options @samples = [] prepare end
Public Instance Methods
Source
# File lib/csv/parser.rb, line 356 def column_separator @column_separator end
Source
# File lib/csv/parser.rb, line 368 def field_size_limit @max_field_size&.succ end
Source
# File lib/csv/parser.rb, line 388 def header_row? @use_headers and @headers.nil? end
Source
# File lib/csv/parser.rb, line 400 def liberal_parsing? @liberal_parsing end
Source
# File lib/csv/parser.rb, line 412 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 __send__(@parse_method, &block) rescue InvalidEncoding if @scanner ignore_broken_line lineno = @lineno else lineno = @lineno + 1 end raise InvalidEncodingError.new(@encoding, lineno) rescue UnexpectedError => error if @scanner ignore_broken_line lineno = @lineno else lineno = @lineno + 1 end message = "This should not be happen: #{error.message}: " message += "Please report this to https://github.com/ruby/csv/issues" raise MalformedCSVError.new(message, lineno) end end
Source
# File lib/csv/parser.rb, line 364 def quote_character @quote_character end
Source
# File lib/csv/parser.rb, line 392 def return_headers? @return_headers end
Source
# File lib/csv/parser.rb, line 380 def unconverted_fields? @unconverted_fields end