Module: ProconBypassMan::Web::SettingParser::Layer::Syntax
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *_args) ⇒ Object
59
60
61
62
|
# File 'lib/procon_bypass_man/web/setting_parser/layer.rb', line 59
def method_missing(name, *_args)
ProconBypassMan::Web.logger.info("unknown layer DSL #{name}")
self
end
|
Instance Method Details
#flip(button, if_pressed: nil, force_neutral: nil) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/procon_bypass_man/web/setting_parser/layer.rb', line 12
def flip(button, if_pressed: nil, force_neutral: nil)
@table[:flip] ||= {}
if if_pressed.nil? && force_neutral.nil?
@table[:flip][button] = nil
else
if if_pressed
if if_pressed.is_a?(Array)
ifp = if_pressed
else
ifp = [if_pressed]
end
end
if force_neutral
if force_neutral.is_a?(Array)
fn = force_neutral
else
fn = [force_neutral]
end
end
@table[:flip][button] = { if_pressed: ifp, force_neutral: fn, enable: true }
end
self
end
|
#initialize(mode:) ⇒ Object
6
7
8
9
10
|
# File 'lib/procon_bypass_man/web/setting_parser/layer.rb', line 6
def initialize(mode: )
@table = {
mode: mode&.to_s,
}.compact
end
|
#macro(name, if_pressed: nil) ⇒ Object
49
50
51
52
53
54
55
56
57
|
# File 'lib/procon_bypass_man/web/setting_parser/layer.rb', line 49
def macro(name, if_pressed: nil)
@table[:macro] ||= {}
if if_pressed.nil?
@table[:macro][name.to_s] = { if_pressed: [] }
else
@table[:macro][name.to_s] = { if_pressed: if_pressed }
end
self
end
|
#remap(button, to: nil) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/procon_bypass_man/web/setting_parser/layer.rb', line 36
def remap(button, to: nil)
case to
when Array
@table[:remap] ||= {}
@table[:remap][button] = { to: to }
when String, Symbol
@table[:remap] ||= {}
@table[:remap][button] = { to: [to] }
end
self
end
|