Class: Opssh::Choice

Inherits:
Object
  • Object
show all
Includes:
Api
Defined in:
lib/opssh/choice.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Api

#instances, #reset_cache, reset_cache, #stacks

Constructor Details

#initializeChoice

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_enabledObject

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_stackObject



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