class MusicXML::Parser

Attributes

filepath[R]
score[R]

Public Class Methods

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

Public Instance Methods

parse() click to toggle source
# File lib/musicxml/parser.rb, line 11
def parse
  document = Nokogiri::XML(File.read(filepath))
  @score = Node::ScorePartwise.new(document.at('score-partwise'))
end

Private Instance Methods

validate_filepath() click to toggle source
# File lib/musicxml/parser.rb, line 18
def validate_filepath
  raise ArgumentError, "Invalid filepath given: #{filepath}" unless File.file?(filepath)
end