Module: CreateRubyGem::UI::BackNavigationPatch Private

Defined in:
lib/create_ruby_gem/ui/back_navigation_patch.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Monkey-patches CLI::UI::Prompt to intercept Ctrl+B for back-navigation.

Defined Under Namespace

Modules: PromptReadCharPatch

Constant Summary collapse

CTRL_B =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

ASCII code for Ctrl+B.

"\u0002"

Class Method Summary collapse

Class Method Details

.apply!void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Prepends the Ctrl+B patch onto CLI::UI::Prompt (idempotent).



33
34
35
36
37
38
# File 'lib/create_ruby_gem/ui/back_navigation_patch.rb', line 33

def self.apply!
  singleton = ::CLI::UI::Prompt.singleton_class
  return if singleton.ancestors.include?(PromptReadCharPatch)

  singleton.prepend(PromptReadCharPatch)
end