Class: PryKeybind::KeySequence

Inherits:
Object
  • Object
show all
Defined in:
lib/pry-keybind.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ KeySequence

Returns a new instance of KeySequence.



124
125
126
# File 'lib/pry-keybind.rb', line 124

def initialize(key)
  @key = key
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



122
123
124
# File 'lib/pry-keybind.rb', line 122

def key
  @key
end

Instance Method Details

#for_readlineObject



128
129
130
131
132
133
134
# File 'lib/pry-keybind.rb', line 128

def for_readline
  unless String === key
    raise ArgumentError, "can't recognize: key.class == #{key.class} / key.inspect == #{key.inspect}"
  end

  [key.chars.map(&:ord)].flatten.pack("C*")
end

#sequence?Boolean

Returns:

  • (Boolean)


136
137
138
# File 'lib/pry-keybind.rb', line 136

def sequence?
  String === key && key.size > 1
end