Class: Reline::Key

Inherits:
Struct show all
Defined in:
lib/reline.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Struct

#as_json, json_create, #pretty_print, #pretty_print_cycle, #to_json

Instance Attribute Details

#charObject

Returns the value of attribute char

Returns:

  • (Object)

    the current value of char



20
21
22
# File 'lib/reline.rb', line 20

def char
  @char
end

#combined_charObject

Returns the value of attribute combined_char

Returns:

  • (Object)

    the current value of combined_char



20
21
22
# File 'lib/reline.rb', line 20

def combined_char
  @combined_char
end

#with_metaObject

Returns the value of attribute with_meta

Returns:

  • (Object)

    the current value of with_meta



20
21
22
# File 'lib/reline.rb', line 20

def with_meta
  @with_meta
end

Instance Method Details

#match?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/reline.rb', line 21

def match?(other)
  case other
  when Reline::Key
    (other.char.nil? or char.nil? or char == other.char) and
    (other.combined_char.nil? or combined_char.nil? or combined_char == other.combined_char) and
    (other.with_meta.nil? or with_meta.nil? or with_meta == other.with_meta)
  when Integer, Symbol
    (combined_char and combined_char == other) or
    (combined_char.nil? and char and char == other)
  else
    false
  end
end