Class: Ansi::Selector::Impl

Inherits:
Object
  • Object
show all
Defined in:
lib/ansi/selector/impl.rb

Direct Known Subclasses

MultiImpl, SingleImpl

Constant Summary collapse

CODES =
{
  standout_mode: `tput rev`,
  exit_standout_mode: `tput rmso`,
  cursor_up: `tput cuu1`,
  cursor_down: `tput cud1`,
  carriage_return_key: `tput cr`
}

Instance Method Summary collapse

Constructor Details

#initialize(options, formatter) ⇒ Impl

Returns a new instance of Impl.



14
15
16
17
18
19
20
# File 'lib/ansi/selector/impl.rb', line 14

def initialize(options, formatter)
  @options = options
  @formatter = formatter

  @highlighted_line_index = 0
  @cursor_line_index = 0
end

Instance Method Details

#selectObject



22
23
24
25
26
27
28
29
30
# File 'lib/ansi/selector/impl.rb', line 22

def select
  print_options
  answer = ask_to_choose
  go_to_line(@options.size)

  answer
ensure
  tty.close
end