module ARD
Constants
- CURRENTUSER
- PLISTFILE
Public Class Methods
create_command(command)
click to toggle source
# File lib/ard.rb, line 69 def self.create_command(command) indexnumber=folder_index(command.foldername).to_i data = Hash.new data2 = Hash.new data2["outputMode"]= command.outputmode data2["script"]= "#{command.script}" data2["user"]= "#{command.user}" data2["userSelect"]= command.userselect data['name'] = "#{command.commandname}" data['state'] = data2 @results[indexnumber]['state'].push(data) @plist.value = CFPropertyList.guess(@results) @plist.save("#{PLISTFILE}", CFPropertyList::List::FORMAT_XML) end
create_empty_folder(new_folder_name)
click to toggle source
# File lib/ard.rb, line 169 def self.create_empty_folder(new_folder_name) indexnumber = @results.count indexnumber = indexnumber.to_i data3=Hash.new data3['name']="#{new_folder_name}" @results.push(data3) state = Array.new @results[indexnumber]["state"] = state @plist.value = CFPropertyList.guess(@results) @plist.save("#{PLISTFILE}", CFPropertyList::List::FORMAT_XML) end
create_folder(command)
click to toggle source
add new folder with command
# File lib/ard.rb, line 55 def self.create_folder(command) data3=Hash.new data3['name']="#{command.foldername}" data3['state']=[data4=Hash.new] data3['state'][0]={"name" => "#{command.commandname}", 'state' => Hash.new} data3['state'][0]['state']['outputMode']= command.outputmode data3['state'][0]['state']['script']= "#{command.script}" data3['state'][0]['state']['user']= "#{command.user}" data3['state'][0]['state']['userSelect']= command.userselect @results.push(data3) @plist.value = CFPropertyList.guess(@results) @plist.save("#{PLISTFILE}", CFPropertyList::List::FORMAT_XML) end
create_spacer(position)
click to toggle source
create a spacer
# File lib/ard.rb, line 85 def self.create_spacer(position) position=position.to_i data3=Hash.new data3['name']="- - - - - - - - - - -" @results.push(data3) indexnumber = folder_index("- - - - - - - - - - -") puts "index is #{indexnumber}" @results.insert(position, @results.delete_at(indexnumber.to_i)) @plist.value = CFPropertyList.guess(@results) @plist.save("#{PLISTFILE}", CFPropertyList::List::FORMAT_XML) end
delete_command(folder_name, command_name)
click to toggle source
delete an exisiting command
# File lib/ard.rb, line 125 def self.delete_command(folder_name, command_name) indexnumber = folder_index("#{folder_name}") indexnumber = indexnumber.to_i command_indexnumber=nil for x in @results[indexnumber]['state'] if x['name'] == "#{command_name}" command_indexnumber = @results[indexnumber]['state'].index(x) end end @results[indexnumber]['state'].delete(@results[indexnumber]['state'][command_indexnumber.to_i]) @plist.value = CFPropertyList.guess(@results) @plist.save("#{PLISTFILE}", CFPropertyList::List::FORMAT_XML) end
delete_folder(folder)
click to toggle source
delete an existing folder
# File lib/ard.rb, line 107 def self.delete_folder(folder) indexnumber = folder_index("#{folder}") indexnumber = indexnumber.to_i @results.delete(@results[indexnumber]) @plist.value = CFPropertyList.guess(@results) @plist.save("#{PLISTFILE}", CFPropertyList::List::FORMAT_XML) end
folder_index(folder)
click to toggle source
find index of folder
# File lib/ard.rb, line 40 def self.folder_index(folder) indexnumber=nil for x in @results if x['name'] == folder indexnumber = @results.index(x) end end if indexnumber.nil? return "Folder does not exist" else return indexnumber end end
list_folders()
click to toggle source
print folder names
# File lib/ard.rb, line 31 def self.list_folders folders=[] for x in @results folders.push(x['name']) end return folders end
move_command(command, move_to_folder)
click to toggle source
# File lib/ard.rb, line 162 def self.move_command(command, move_to_folder) @results[ARD.folder_index(move_to_folder)]["state"] << @results[ARD.folder_index(command)] @plist.value = CFPropertyList.guess(@results) @plist.save("#{PLISTFILE}", CFPropertyList::List::FORMAT_XML) ARD.delete_folder(command) end
move_folder(originialposition, newposition)
click to toggle source
move an exisiting folders poistion
# File lib/ard.rb, line 98 def self.move_folder(originialposition, newposition) newposition=newposition.to_i originialposition=originialposition.to_i @results.insert(newposition, @results.delete_at(originialposition)) @plist.value = CFPropertyList.guess(@results) @plist.save("#{PLISTFILE}", CFPropertyList::List::FORMAT_XML) end
options()
click to toggle source
# File lib/ard.rb, line 158 def self.options puts ARD.methods(false).sort end
rename_command(folder_name, orignialcommandname, newcommandname)
click to toggle source
rename an exisiting command
# File lib/ard.rb, line 142 def self.rename_command(folder_name, orignialcommandname, newcommandname) indexnumber = folder_index("#{folder_name}") indexnumber = indexnumber.to_i command_indexnumber=nil for x in @results[indexnumber]['state'] if x['name'] == "#{orignialcommandname}" command_indexnumber = @results[indexnumber]['state'].index(x) end end @results[indexnumber]['state'][command_indexnumber]['name'] = "#{newcommandname}" @plist.value = CFPropertyList.guess(@results) @plist.save("#{PLISTFILE}", CFPropertyList::List::FORMAT_XML) end
rename_folder(oldname, newname)
click to toggle source
rename an exisiting folder
# File lib/ard.rb, line 116 def self.rename_folder(oldname, newname) indexnumber = folder_index("#{oldname}") indexnumber = indexnumber.to_i @results[indexnumber]['name'] = newname @plist.value = CFPropertyList.guess(@results) @plist.save("#{PLISTFILE}", CFPropertyList::List::FORMAT_XML) end