Method: RunLoop::PlistBuddy#unshift_array
- Defined in:
- lib/run_loop/plist_buddy.rb
#unshift_array(key, type, value, path, opts = {}) ⇒ Object
Add value to the head of an array type.
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/run_loop/plist_buddy.rb', line 153 def unshift_array(key, type, value, path, opts={}) if !plist_key_exists?(key, path) run_command("Add :#{key} array", path, opts) else key_type = plist_read(key, path).split(" ")[0] if key_type != "Array" raise RuntimeError, %Q[ Could not push #{value} onto array: Expected: key #{key} be of type Array Found: had type #{key_type} in plist: #{path} ] end end run_command("Add :#{key}:0 #{type} #{value}", path, opts) end |