summaryrefslogtreecommitdiff
path: root/lib/reline.rb
diff options
context:
space:
mode:
authormanga_osyo <[email protected]>2021-10-02 08:44:22 +0900
committergit <[email protected]>2021-10-02 19:58:41 +0900
commitb8327fb8b10615ddb3f5e1978d6d83be465503a9 ()
treef821dbcebffee34e22f624d6fb9c6e14f8d8d2ea /lib/reline.rb
parentabc0304cb28cb9dcc3476993bc487884c139fd11 (diff)
[ruby/reline] Refactoring Reline::Key.match? and add test.
https://.com/ruby/reline/commit/90e8999ae4
-rw-r--r--lib/reline.rb22
1 files changed, 9 insertions, 13 deletions
@@ -17,19 +17,15 @@ module Reline
class ConfigEncodingConversionError < StandardError; end
Key = Struct.new('Key', :char, :combined_char, :with_meta) do
- def match?(key)
- if key.instance_of?(Reline::Key)
- (key.char.nil? or char.nil? or char == key.char) and
- (key.combined_char.nil? or combined_char.nil? or combined_char == key.combined_char) and
- (key.with_meta.nil? or with_meta.nil? or with_meta == key.with_meta)
- elsif key.is_a?(Integer) or key.is_a?(Symbol)
- if not combined_char.nil? and combined_char == key
- true
- elsif combined_char.nil? and not char.nil? and char == key
- true
- else
- false
- end
else
false
end