Class: Downup::Base

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

Instance Method Summary collapse

Constructor Details

#initialize(options:, flash_message: nil, flash_color: :green, default_color: :brown, selected_color: :magenta, selector: "‣", stdin: $stdin, stdout: $stdout, header_proc: Proc.new {}) ⇒ Base

Returns a new instance of Base.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/downup.rb', line 10

def initialize(options:,
               flash_message: nil,
               flash_color: :green,
               default_color: :brown,
               selected_color: :magenta,
               selector: "‣",
               stdin: $stdin,
               stdout: $stdout,
               header_proc: Proc.new {})

  @options        = options
  @flash_color    = flash_color
  @flash_message  = flash_message
  @default_color  = default_color
  @selected_color = selected_color
  @selector       = selector
  @header_proc    = header_proc
  @stdin          = stdin
  @stdout         = stdout
  @colonel        = Kernel
end

Instance Method Details

#prompt(position = 0) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/downup.rb', line 32

def prompt(position = 0)
  @selected_position = position_selector(position)
  colonel.system("clear")
  header_proc.call
  print_flash
  Downup::OptionsPrinter.new(
    options: options,
    selected_position: @selected_position,
    default_color: default_color,
    selected_color: selected_color,
    selector: selector
  ).print_options
  stdout.print "\n> "
  input = read_char
  process_input input
end