Module: Vigilem::Win32API::Eventable Abstract
- Included in:
- InputSystemHandler
- Defined in:
- lib/vigilem/win32_api/eventable.rb
Overview
This module is abstract.
included into the same module as RubyizedAPI or respond_to? [:read_console_input, :peek_console_input]
Instance Method Summary collapse
-
#has_any? ⇒ TrueClass || FalseClass
checks whether the input buffer has events.
-
#read_many(number_of_events = 1) ⇒ Array
blocks until the specified number of events are read.
- #read_many_nonblock(limit = 1) ⇒ Array
-
#read_one ⇒ Array
blocking reads one event from the input buffer.
-
#read_one_nonblock ⇒ InputRecord
non_blocking commonly used with event processing.
Instance Method Details
#has_any? ⇒ TrueClass || FalseClass
checks whether the input buffer has events
37 38 39 |
# File 'lib/vigilem/win32_api/eventable.rb', line 37 def has_any? peek_console_input.size > 0 end |
#read_many(number_of_events = 1) ⇒ Array
blocks until the specified number of events are read
16 17 18 |
# File 'lib/vigilem/win32_api/eventable.rb', line 16 def read_many(number_of_events=1) read_console_input({:nLength => number_of_events, :blocking => true }) end |
#read_many_nonblock(limit = 1) ⇒ Array
9 10 11 |
# File 'lib/vigilem/win32_api/eventable.rb', line 9 def read_many_nonblock(limit=1) [*(read_console_input({:nLength => limit, :blocking => false }) if has_any?)] end |
#read_one ⇒ Array
blocking reads one event from the input buffer
31 32 33 |
# File 'lib/vigilem/win32_api/eventable.rb', line 31 def read_one read_console_input.shift end |
#read_one_nonblock ⇒ InputRecord
non_blocking commonly used with event processing
24 25 26 |
# File 'lib/vigilem/win32_api/eventable.rb', line 24 def read_one_nonblock read_one if has_any? end |