Class: Tagline::CharacterReader

Inherits:
Object
  • Object
show all
Includes:
HighLine::SystemExtensions
Defined in:
lib/tagline/character_reader.rb

Direct Known Subclasses

Tagger

Constant Summary collapse

UP =
72
DOWN =
80
N =
110
CTRL_X =
24

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run_loop(*args) ⇒ Object



7
8
9
# File 'lib/tagline/character_reader.rb', line 7

def self.run_loop(*args)
  new(*args).run_loop
end

Instance Method Details

#run_loopObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/tagline/character_reader.rb', line 16

def run_loop
  before_loop
  loop do
    case char = get_character.ord
    when UP
      up_key
    when DOWN
      down_key
    when N
      n_key
    when CTRL_X
      break
    else
      tag(char)
    end
  end
ensure
  after_loop
  exit
end