class ProconBypassMan::Web::SettingParser::Core::Layer

Public Class Methods

new(mode: ) click to toggle source
# File lib/procon_bypass_man/web/setting_parser.rb, line 17
def initialize(mode: )
  @table = {
    mode: mode&.to_s,
  }.compact
end

Public Instance Methods

flip(button, if_pressed: nil, force_neutral: nil) click to toggle source
# File lib/procon_bypass_man/web/setting_parser.rb, line 23
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
macro(name, if_pressed: nil) click to toggle source
# File lib/procon_bypass_man/web/setting_parser.rb, line 60
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) click to toggle source
# File lib/procon_bypass_man/web/setting_parser.rb, line 47
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
to_hash() click to toggle source
# File lib/procon_bypass_man/web/setting_parser.rb, line 70
def to_hash
  @table
end