Class: RelinePac::Config
- Inherits:
-
Object
- Object
- RelinePac::Config
- Defined in:
- lib/reline_pac/config.rb
Overview
Config manages Reline keybindings and package installation.
Instance Method Summary collapse
-
#add_keybind(key, method) ⇒ Object
Add a keybinding that invokes the given LineEditor method symbol.
-
#add_package(method_name) { ... } ⇒ Object
Add a custom package (method) to Reline::LineEditor.
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
6 7 8 |
# File 'lib/reline_pac/config.rb', line 6 def initialize Packages.install_all end |
Instance Method Details
#add_keybind(key, method) ⇒ Object
Add a keybinding that invokes the given LineEditor method symbol.
26 27 28 29 |
# File 'lib/reline_pac/config.rb', line 26 def add_keybind(key, method) key_bytes = key.bytes reline_config.add_default_key_binding(key_bytes, method) end |
#add_package(method_name) { ... } ⇒ Object
Add a custom package (method) to Reline::LineEditor.
13 14 15 16 17 18 19 20 21 |
# File 'lib/reline_pac/config.rb', line 13 def add_package(method_name, &block) raise ArgumentError, 'add_package requires a block to define the package method body' unless block_given? Packages::Custom.module_eval do define_method(method_name, &block) end Reline::LineEditor.prepend(Packages::Custom) unless Reline::LineEditor.ancestors.include?(Packages::Custom) end |