Improve robustness

This commit is contained in:
Matthias Neeracher 2007-08-30 22:34:22 +00:00
parent 7a155ad3f1
commit 5696f5d649
2 changed files with 11 additions and 7 deletions

View File

@ -35,10 +35,14 @@ def _identification
poet.add_attribute('type', 'poet') poet.add_attribute('type', 'poet')
ident.add_element(poet) ident.add_element(poet)
encoding = REXML::Element.new('encoding') encoding = REXML::Element.new('encoding')
if INPUT['saved']
date = newTextElement('encoding-date', INPUT['saved'].strftime("%Y-%m-%d")) date = newTextElement('encoding-date', INPUT['saved'].strftime("%Y-%m-%d"))
encoding.add_element(date) encoding.add_element(date)
software = newTextElement('software', INPUT['software']) end
encoding.add_element(software) if INPUT['software']
software = newTextElement('software', INPUT['software']) if INPUT['software']
encoding.add_element(software)
end
ident.add_element(encoding) ident.add_element(encoding)
return ident return ident
@ -215,7 +219,7 @@ def _melody
end end
meas['melody'].each do |note| meas['melody'].each do |note|
dur = (note['durNum'] * $DIVISIONS * 4) / note['durDenom'] dur = (note['durNum'] * $DIVISIONS * 4) / note['durDenom']
n = _note(note['pitch'], dur, note['tied']) n = _note(note['pitch'], dur, note['tied'] || 0)
stanza = 1 stanza = 1
note['lyrics'].each do |syll| note['lyrics'].each do |syll|
if syll['text'] if syll['text']
@ -226,7 +230,7 @@ def _melody
n.add_element(lyr) n.add_element(lyr)
end end
stanza += 1 stanza += 1
end end if note['lyrics']
m.add_element(n) m.add_element(n)
end end
if r = meas['end-repeat'] if r = meas['end-repeat']

View File

@ -47,7 +47,7 @@ class PlistListener
def text(text) def text(text)
case @kind case @kind
when "string", "key" then when "string", "key" then
@obj = text @obj += text
when "data" then when "data" then
@obj = Base64.decode(text) @obj = Base64.decode(text)
when "date" then when "date" then