lib/tty/reader/win_console.rb in tty-reader-0.8.0 vs lib/tty/reader/win_console.rb in tty-reader-0.9.0
- old
+ new
@@ -30,29 +30,30 @@
@escape_codes = [[NUL_HEX.ord], [ESC.ord], EXT_HEX.bytes.to_a]
end
# Get a character from console blocking for input
#
- # @param [Hash[Symbol]] options
- # @option options [Symbol] :echo
- # the echo mode toggle
- # @option options [Symbol] :raw
- # the raw mode toggle
+ # @param [Boolean] echo
+ # whether to echo input back or not, defaults to true
+ # @param [Boolean] raw
+ # whether to use raw mode or not, defaults to false
+ # @param [Boolean] nonblock
+ # whether to wait for input or not, defaults to false
#
# @return [String]
#
# @api private
- def get_char(options)
- if options[:raw] && options[:echo]
- if options[:nonblock]
+ def get_char(echo: true, raw: false, nonblock: false)
+ if raw && echo
+ if nonblock
get_char_echo_non_blocking
else
get_char_echo_blocking
end
- elsif options[:raw] && !options[:echo]
- options[:nonblock] ? get_char_non_blocking : get_char_blocking
- elsif !options[:raw] && !options[:echo]
- options[:nonblock] ? get_char_non_blocking : get_char_blocking
+ elsif raw && !echo
+ nonblock ? get_char_non_blocking : get_char_blocking
+ elsif !raw && !echo
+ nonblock ? get_char_non_blocking : get_char_blocking
else
@input.getc
end
end