Class: HammerCLI::CSVParser
- Inherits:
-
Object
- Object
- HammerCLI::CSVParser
- Defined in:
- lib/hammer_cli/csv_parser.rb
Instance Method Summary collapse
-
#initialize ⇒ CSVParser
constructor
A new instance of CSVParser.
- #parse(data) ⇒ Object
Constructor Details
#initialize ⇒ CSVParser
Returns a new instance of CSVParser.
4 5 6 |
# File 'lib/hammer_cli/csv_parser.rb', line 4 def initialize reset_parser end |
Instance Method Details
#parse(data) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/hammer_cli/csv_parser.rb', line 8 def parse(data) return [] if data.nil? reset_parser data.each_char do |char| handle_escape(char) || handle_quoting(char) || handle_comma(char) || add_to_buffer(char) end raise ArgumentError.new(_("Illegal quoting in %{buffer}") % { :buffer => @raw_buffer }) unless @last_quote.nil? clean_buffer @value end |