Class: AddWish
- Inherits:
-
Djinni::Wish
- Object
- Djinni::Wish
- AddWish
- Defined in:
- lib/zoom/wish/add_wish.rb
Instance Method Summary collapse
- #aliases ⇒ Object
- #description ⇒ Object
- #execute(args, djinni_env = {}) ⇒ Object
-
#initialize ⇒ AddWish
constructor
A new instance of AddWish.
- #tab_complete(input, djinni_env = {}) ⇒ Object
- #usage ⇒ Object
Constructor Details
Instance Method Details
#aliases ⇒ Object
4 5 6 |
# File 'lib/zoom/wish/add_wish.rb', line 4 def aliases return ["add", "new"] end |
#description ⇒ Object
8 9 10 |
# File 'lib/zoom/wish/add_wish.rb', line 8 def description return "Create a new profile" end |
#execute(args, djinni_env = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/zoom/wish/add_wish.rb', line 12 def execute(args, djinni_env = {}) if (args.split(" ").length != 2) usage return end config = djinni_env["config"] c, n = args.split(" ") if (config.has_profile?(n)) puts("Profile already exists: #{n}") elsif (!@classes.has_key?(c)) puts("Class does not exist: #{c}") else profiles = config.parse_profiles profiles[n] = Zoom::Profile.profile_by_name(c).new(n) config.set_profiles(profiles) end end |
#tab_complete(input, djinni_env = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/zoom/wish/add_wish.rb', line 39 def tab_complete(input, djinni_env = {}) return [{}, "", ""] if (input.include?(" ")) completions = @classes.select do |clas, desc| clas.downcase.start_with?(input.downcase) end return [completions, input, " "] end |
#usage ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/zoom/wish/add_wish.rb', line 49 def usage puts("#{aliases.join(", ")} <class> <name>") puts(" #{description}.") puts puts("CLASSES") @classes.each do |clas, desc| puts(" #{clas}") end end |