Class: ForemanMaintain::CSVParser
- Inherits:
-
Object
- Object
- ForemanMaintain::CSVParser
- Defined in:
- lib/foreman_maintain/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.
3 4 5 |
# File 'lib/foreman_maintain/csv_parser.rb', line 3 def initialize reset_parser end |
Instance Method Details
#parse(data) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/foreman_maintain/csv_parser.rb', line 7 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 unless @last_quote.nil? raise(ArgumentError, format('Illegal quoting in %s', @raw_buffer)) end clean_buffer @value end |