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) ⇒ Impl

Returns a new instance of Impl.



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

def initialize(options)
  @options = options

  @highlighted_line_index = 0
  @cursor_line_index = 0
end

Instance Method Details

#selectObject



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

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

  answer
ensure
  tty.close
end