module MusicalScore::IO
Public Class Methods
export_xml(path, score)
click to toggle source
# File lib/musical_score/io/exporter.rb, line 6 def export_xml(path, score) formatter = REXML::Formatters::Pretty.new(4) formatter.compact = true File.open(path, 'w') do |file| formatter.write(score.export_xml, file) end end
import(file)
click to toggle source
# File lib/musical_score/io/importer.rb, line 6 def import(file) extname = File.extname(file) case extname when ".xml" return import_xml_via_hash(file) else raise MusicalScore::InvalidFileType end end
import_xml(file_path)
click to toggle source
# File lib/musical_score/io/importer.rb, line 15 def import_xml(file_path) doc = REXML::Document.new(File.new(file_path)) score = MusicalScore::Score::Score.create_by_xml(doc, file_path) return score end
import_xml_via_hash(file_path)
click to toggle source
# File lib/musical_score/io/importer.rb, line 21 def import_xml_via_hash(file_path) doc = XmlSimple.xml_in(open(file_path)) score = MusicalScore::Score::Score.create_by_hash(doc, file_path) return score end
Private Instance Methods
export_xml(path, score)
click to toggle source
# File lib/musical_score/io/exporter.rb, line 6 def export_xml(path, score) formatter = REXML::Formatters::Pretty.new(4) formatter.compact = true File.open(path, 'w') do |file| formatter.write(score.export_xml, file) end end
import(file)
click to toggle source
# File lib/musical_score/io/importer.rb, line 6 def import(file) extname = File.extname(file) case extname when ".xml" return import_xml_via_hash(file) else raise MusicalScore::InvalidFileType end end
import_xml(file_path)
click to toggle source
# File lib/musical_score/io/importer.rb, line 15 def import_xml(file_path) doc = REXML::Document.new(File.new(file_path)) score = MusicalScore::Score::Score.create_by_xml(doc, file_path) return score end
import_xml_via_hash(file_path)
click to toggle source
# File lib/musical_score/io/importer.rb, line 21 def import_xml_via_hash(file_path) doc = XmlSimple.xml_in(open(file_path)) score = MusicalScore::Score::Score.create_by_hash(doc, file_path) return score end