Class: Opssh::Choice
Instance Attribute Summary collapse
-
#caching_enabled ⇒ Object
Returns the value of attribute caching_enabled.
Instance Method Summary collapse
-
#initialize ⇒ Choice
constructor
A new instance of Choice.
- #select_instance(stack_id) ⇒ Object
- #select_stack ⇒ Object
Methods included from Api
#instances, #reset_cache, reset_cache, #stacks
Constructor Details
#initialize ⇒ Choice
Returns a new instance of Choice.
11 12 13 |
# File 'lib/opssh/choice.rb', line 11 def initialize @caching_enabled = true end |
Instance Attribute Details
#caching_enabled ⇒ Object
Returns the value of attribute caching_enabled.
9 10 11 |
# File 'lib/opssh/choice.rb', line 9 def caching_enabled @caching_enabled end |
Instance Method Details
#select_instance(stack_id) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/opssh/choice.rb', line 24 def select_instance(stack_id) instance_list = instances(stack_id) raise "Sorry, no instance available in this stack." if instance_list.size < 1 show_list(instance_list) index = ask("\n--> Please select instance:") instance_list[index.to_i - 1] rescue nil unless index.to_i == 0 end |
#select_stack ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/opssh/choice.rb', line 15 def select_stack stack_list = stacks raise "Sorry, no stacks available." if stack_list.size < 1 show_list(stack_list) index = ask("\n--> Please select stack:") puts "Index: #{index} and #{stack_list[index.to_i - 1].inspect}" stack_list[index.to_i - 1] rescue nil unless index.to_i == 0 end |