Class: LabelSelector

Inherits:
Object show all
Defined in:
lib/label_selector.rb

Class Method Summary collapse

Class Method Details

.choose_from(list) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/label_selector.rb', line 6

def self.choose_from(list)
  view = selecta(list)
  print view
  STDIN.gets
rescue Interrupt => e
  clear_screen
  exit 0
end

.clear_screenObject



23
24
25
# File 'lib/label_selector.rb', line 23

def self.clear_screen
  print "\e[2J\e[H"
end

.selecta(list) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/label_selector.rb', line 15

def self.selecta(list)
  clear_screen
  Selecta.new.main_api(keys: list.map(&:name),
                       values: list.map { |e| ListColorizer.call(e.to_s(detail: true)) },
                       options: { height: "full" })
  clear_screen
end