class ProconBypassMan::Configuration

Constants

MODES

Attributes

context[RW]
current_context_key[RW]
layers[RW]
macro_plugins[RW]
mode_plugins[RW]
setting_path[RW]

Public Class Methods

instance() click to toggle source
# File lib/procon_bypass_man/configuration.rb, line 15
def self.instance
  @@current_context_key ||= :main
  @@context ||= {}
  @@context[@@current_context_key] ||= new
end
new() click to toggle source
# File lib/procon_bypass_man/configuration.rb, line 34
def initialize
  reset!
end
switch_new_context(key) { |context| ... } click to toggle source
# File lib/procon_bypass_man/configuration.rb, line 21
def self.switch_new_context(key)
  @@context[key] = new
  previous_key = @@current_context_key
  if block_given?
    @@current_context_key = key
    value = yield(@@context[key])
    @@current_context_key = previous_key
    return value
  else
    @@current_context_key = key
  end
end

Public Instance Methods

install_macro_plugin(klass) click to toggle source
# File lib/procon_bypass_man/configuration.rb, line 60
def install_macro_plugin(klass)
  ProconBypassMan::Procon::MacroRegistry.install_plugin(klass)
  self
end
install_mode_plugin(klass) click to toggle source
# File lib/procon_bypass_man/configuration.rb, line 55
def install_mode_plugin(klass)
  ProconBypassMan::Procon::ModeRegistry.install_plugin(klass)
  self
end
layer(direction, mode: :manual, &block) click to toggle source
# File lib/procon_bypass_man/configuration.rb, line 39
def layer(direction, mode: :manual, &block)
  if mode.respond_to?(:name)
    mode_name = mode.name.to_sym
  else
    mode_name = mode
  end
  unless (MODES + ProconBypassMan::Procon::ModeRegistry.plugins.keys).include?(mode_name)
    raise("#{mode_name} mode is unknown")
  end

  layer = Layer.new(mode: mode_name)
  layer.instance_eval(&block) if block_given?
  self.layers[direction] = layer
  self
end
prefix_keys() click to toggle source
# File lib/procon_bypass_man/configuration.rb, line 70
def prefix_keys
  @prefix_keys_for_changing_layer
end
prefix_keys_for_changing_layer(buttons) click to toggle source
# File lib/procon_bypass_man/configuration.rb, line 65
def prefix_keys_for_changing_layer(buttons)
  @prefix_keys_for_changing_layer = buttons
  self
end
reset!() click to toggle source
# File lib/procon_bypass_man/configuration.rb, line 74
def reset!
  @prefix_keys_for_changing_layer = []
  self.mode_plugins = {}
  self.macro_plugins = {}
  self.layers = {
    up: Layer.new,
    down: Layer.new,
    left: Layer.new,
    right: Layer.new,
  }
end