class SublimeDSL::TextMate::Preference::PListWriter
Attributes
preference[R]
root[R]
Public Class Methods
new(preference)
click to toggle source
# File lib/sublime_dsl/textmate/preference.rb, line 249 def initialize(preference) @preference = preference @root = {} convert end
Public Instance Methods
export(file)
click to toggle source
# File lib/sublime_dsl/textmate/preference.rb, line 255 def export(file) PList.export(root, file) end
Private Instance Methods
convert()
click to toggle source
# File lib/sublime_dsl/textmate/preference.rb, line 261 def convert root['name'] = preference.name root['scope'] = preference.scope if preference.scope root['uuid'] = preference.uuid if preference.uuid root['bundleUUID'] = preference.bundle_uuid if preference.bundle_uuid root['settings'] = convert_hash(preference.settings) end
convert_array(list)
click to toggle source
# File lib/sublime_dsl/textmate/preference.rb, line 281 def convert_array(list) list.map { |o| convert_object o } end
convert_hash(h)
click to toggle source
# File lib/sublime_dsl/textmate/preference.rb, line 285 def convert_hash(h) out = {} h.each_pair { |k,v| out[k] = convert_object(v) } out end
convert_object(object)
click to toggle source
# File lib/sublime_dsl/textmate/preference.rb, line 269 def convert_object(object) case object when Array then convert_array object when Hash then convert_hash object when Tools::RegexpWannabe then object.to_s # TODO: booleans as 1/0 or true/false? when TrueClass then 1 when FalseClass then 0 else object # String, Integer, NilClass end end