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