You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
xremap/mrblib/xkremap/config_dsl.rb

23 lines
437 B
Ruby

module Xkremap
class ConfigDSL
# @param [Xkremap::Config] config
def initialize(config)
@config = config
end
def remap(from_str, options = {})
to_strs = Array(options.fetch(:to))
@config.remaps << Config::Remap.new(
compile_exp(from_str),
to_strs.map { |str| compile_exp(str) }
)
end
private
def compile_exp(str)
KeyExpression.compile(str)
end
end
end