mirror of
https://github.com/microtherion/VocalEasel.git
synced 2024-12-22 19:23:59 +00:00
Encode true/false, sort keys
This commit is contained in:
parent
8dacdf5dea
commit
e1c8e71c86
|
@ -18,6 +18,10 @@ end
|
||||||
def _encodePlist(object)
|
def _encodePlist(object)
|
||||||
e = nil
|
e = nil
|
||||||
case object
|
case object
|
||||||
|
when false then
|
||||||
|
e = REXML::Element.new("false")
|
||||||
|
when true then
|
||||||
|
e = REXML::Element.new("true")
|
||||||
when String then
|
when String then
|
||||||
e = REXML::Element.new("string")
|
e = REXML::Element.new("string")
|
||||||
e.add_text(object)
|
e.add_text(object)
|
||||||
|
@ -40,11 +44,11 @@ def _encodePlist(object)
|
||||||
end
|
end
|
||||||
when Hash then
|
when Hash then
|
||||||
e = REXML::Element.new("dict")
|
e = REXML::Element.new("dict")
|
||||||
object.each do |key,elt|
|
object.keys.sort.each do |key|
|
||||||
k = REXML::Element.new("key")
|
k = REXML::Element.new("key")
|
||||||
k.add_text(key)
|
k.add_text(key)
|
||||||
e.add_element(k)
|
e.add_element(k)
|
||||||
e.add_element(_encodePlist(elt))
|
e.add_element(_encodePlist(object[key]))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise "plistWriter can't encode objects of type `#{object.class}'"
|
raise "plistWriter can't encode objects of type `#{object.class}'"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user