Module: Karabiner::DSL::Item

Included in:
Item
Defined in:
lib/karabiner/dsl/item.rb

Constant Summary collapse

AVAILABLE_PROPERTIES =
%i[
  name
  identifier
  autogen
].freeze

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(property, value = '', options = {}) ⇒ Object (private)



36
37
38
39
40
41
42
43
# File 'lib/karabiner/dsl/item.rb', line 36

def method_missing(property, value = '', options = {})
  if AVAILABLE_PROPERTIES.include?(property)
    property = Karabiner::Property.new(property, value, options)
    add_child(property)
  else
    super
  end
end

Instance Method Details

#execute(script) ⇒ Object



29
30
31
32
# File 'lib/karabiner/dsl/item.rb', line 29

def execute(script)
  Karabiner::History.register_script(script)
  Karabiner::Vkopenurldef.script_keycode(script)
end

#invoke(application) ⇒ Object



24
25
26
27
# File 'lib/karabiner/dsl/item.rb', line 24

def invoke(application)
  Karabiner::History.register_application(application)
  Karabiner::Vkopenurldef.application_keycode(application)
end

#remap(target, options = {}) ⇒ Object



14
15
16
17
# File 'lib/karabiner/dsl/item.rb', line 14

def remap(target, options = {})
  remap = Karabiner::Remap.new(target, options[:to])
  add_child(remap)
end

#show_message(message) ⇒ Object



19
20
21
22
# File 'lib/karabiner/dsl/item.rb', line 19

def show_message(message)
  property = Karabiner::Property.new("autogen", "__ShowStatusMessage__ #{message}")
  add_child(property)
end