class Highlights::Parser

Constants

NOTES_STARTING_POSITION

Public Class Methods

new(filename) click to toggle source
# File lib/highlights/parser.rb, line 6
def initialize(filename)
  @filename = filename
end

Public Instance Methods

parse() click to toggle source
# File lib/highlights/parser.rb, line 10
def parse
  table = CSV.read(@filename, liberal_parsing: true)

  notes = table[NOTES_STARTING_POSITION...].map do |note_row|
    Note.new(*note_row)
  end

  Document.new(table[1][0], table[2][0], notes)
rescue StandardError => e
  raise MalformedCSVError.new(e.message)
end