Class: SublimeDSL::SublimeText::KeyMap::DSLReader

Inherits:
Tools::BlankSlate show all
Defined in:
lib/sublime_dsl/sublime_text/keymap/dsl_reader.rb

Overview

Keymap DSL interpreter.

Constant Summary

Constants inherited from Tools::BlankSlate

Tools::BlankSlate::KEPT_METHODS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file = nil) ⇒ DSLReader

Returns a new instance of DSLReader.



14
15
16
17
18
# File 'lib/sublime_dsl/sublime_text/keymap/dsl_reader.rb', line 14

def initialize(file = nil)
  @keymaps = []
  @_file = file
  instance_eval File.read(file, encoding: 'utf-8'), file if file
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



24
25
26
# File 'lib/sublime_dsl/sublime_text/keymap/dsl_reader.rb', line 24

def method_missing(sym, *args, &block)
  "invalid DSL statement: '#{sym}'"
end

Instance Attribute Details

#_fileObject

Returns the value of attribute _file.



12
13
14
# File 'lib/sublime_dsl/sublime_text/keymap/dsl_reader.rb', line 12

def _file
  @_file
end

Instance Method Details

#_keymapsObject



20
21
22
# File 'lib/sublime_dsl/sublime_text/keymap/dsl_reader.rb', line 20

def _keymaps
  @keymaps
end

#keymap(name, &block) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/sublime_dsl/sublime_text/keymap/dsl_reader.rb', line 28

def keymap(name, &block)
  reader = BindingReader.new(_file)
  reader.instance_eval(&block)
# unless reader._catchers_hash.empty?
#   reader._catchers_hash.each_pair { |i,c| p c }
# end
  map = KeyMap.new(name, reader._keyboard)
  map.bindings.concat reader._bindings
  @keymaps << map
end