Class: NvimConf::Managers::Mappings
- Inherits:
-
Object
- Object
- NvimConf::Managers::Mappings
- Defined in:
- lib/nvim_conf/managers/mappings.rb
Constant Summary collapse
- AVAILABLE_METHODS =
%w[map map! nmap vmap imap cmap smap xmap omap lmap tmap]
Instance Attribute Summary collapse
-
#mappings ⇒ Object
readonly
Returns the value of attribute mappings.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(namespace) ⇒ Mappings
constructor
A new instance of Mappings.
- #new(binding, action) ⇒ Object (also: #m)
- #store? ⇒ Boolean
- #validate! ⇒ Object
Constructor Details
#initialize(namespace) ⇒ Mappings
Returns a new instance of Mappings.
10 11 12 13 14 15 |
# File 'lib/nvim_conf/managers/mappings.rb', line 10 def initialize(namespace) @mappings = [] @namespace = namespace&.to_s validate! end |
Instance Attribute Details
#mappings ⇒ Object (readonly)
Returns the value of attribute mappings.
8 9 10 |
# File 'lib/nvim_conf/managers/mappings.rb', line 8 def mappings @mappings end |
Class Method Details
.section_name ⇒ Object
18 19 20 |
# File 'lib/nvim_conf/managers/mappings.rb', line 18 def section_name "Mappings" end |
Instance Method Details
#new(binding, action) ⇒ Object Also known as: m
49 50 51 52 53 54 55 56 |
# File 'lib/nvim_conf/managers/mappings.rb', line 49 def new(binding, action) raise "No namespace was given for <mappings>" unless @namespace raise "No namespace was given for <mappings>" if @namespace.empty? store_mapping( @namespace, binding, action ) end |
#store? ⇒ Boolean
29 30 31 |
# File 'lib/nvim_conf/managers/mappings.rb', line 29 def store? @mappings.any? end |
#validate! ⇒ Object
23 24 25 26 27 |
# File 'lib/nvim_conf/managers/mappings.rb', line 23 def validate! return if @namespace.nil? || @namespace.empty? raise "Invalid namespace given for <mappings>: #{@namespace}" unless AVAILABLE_METHODS.include?(@namespace) end |