Class: Downup::Base

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

Instance Method Summary collapse

Constructor Details

#initialize(options:, title: nil, 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
# File 'lib/downup.rb', line 10

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

  @options        = options
  @title          = title
  @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



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

def prompt(position = 0)
  @selected_position = position_selector(position)
  colonel.system("clear")
  header_proc.call
  print_title
  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