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.



133
134
135
# File 'lib/pry-keybind.rb', line 133

def initialize(key)
  @key = key
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



131
132
133
# File 'lib/pry-keybind.rb', line 131

def key
  @key
end

Instance Method Details

#for_readlineObject



137
138
139
140
141
142
143
# File 'lib/pry-keybind.rb', line 137

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)


145
146
147
# File 'lib/pry-keybind.rb', line 145

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