Class: CWG::MonitorKeys

Inherits:
Object
  • Object
show all
Defined in:
/Users/martyn/cw/cw_clone/lib/cw/monitor_keys.rb

Instance Method Summary (collapse)

Constructor Details

- (MonitorKeys) initialize(cw)

Returns a new instance of MonitorKeys



9
10
11
12
13
# File '/Users/martyn/cw/cw_clone/lib/cw/monitor_keys.rb', line 9

def initialize(cw)
  @cw = cw
  @key_input = KeyInput.new
  @queue     = Queue.new
end

Instance Method Details

- (Boolean) empty?

Returns:

  • (Boolean)


19
20
21
# File '/Users/martyn/cw/cw_clone/lib/cw/monitor_keys.rb', line 19

def empty?
  @queue.empty?
end

- (Boolean) have_data?

Returns:

  • (Boolean)


23
24
25
# File '/Users/martyn/cw/cw_clone/lib/cw/monitor_keys.rb', line 23

def have_data?
  ! empty?
end

- (Object) key_input



15
16
17
# File '/Users/martyn/cw/cw_clone/lib/cw/monitor_keys.rb', line 15

def key_input
  @key_input ||= KeyInput.new
end

- (Object) monitor_keys



27
28
29
30
31
32
33
34
35
36
37
38
# File '/Users/martyn/cw/cw_clone/lib/cw/monitor_keys.rb', line 27

def monitor_keys
  loop do
    get_key_input
    break if check_quit_key_input
    if @cw.quit
      key_input.reset
      break
    end
    check_sentence_navigation key_chr if self.class == Book
    build_word_maybe
  end
end