Class: Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/pandoras_box/install.rb

Class Method Summary collapse

Class Method Details

.installObject



6
7
8
# File 'lib/pandoras_box/install.rb', line 6

def install
  prompt_install
end

.prompt_installObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/pandoras_box/install.rb', line 10

def prompt_install
  titles          = Box.default_boxes.map { |box| box.name }
  boxes           = Box.default_boxes

  if CLI.prompt_boolean('Would you like to see all boxes')
    titles = Box.boxes.map { |box| box.name }
    boxes = Box.boxes
  end
  continue        = true
  response_number = nil

  while continue
    response        = CLI.prompt_multiple_choice('Install Box', titles, 'For description, respond with <#>d')
    response_number = response.to_i
    if response.include? 'd'
      response_number = response.delete!('d').to_i
      if CLI.prompt_description(boxes[response_number].name, boxes[response_number].description)
        continue = false
      end
    else
      continue = false
    end
  end

  unless response_number.nil?
    boxes[response_number].install
  end
end