class ProconBypassMan::Configuration::Validator
Public Class Methods
new(config)
click to toggle source
# File lib/procon_bypass_man/configuration/validator.rb, line 4 def initialize(config) @layers = config.layers @prefix_keys = config.prefix_keys end
Public Instance Methods
errors()
click to toggle source
@return [Hash]
# File lib/procon_bypass_man/configuration/validator.rb, line 27 def errors @errors ||= Hash.new {|h,k| h[k] = [] } end
invalid?()
click to toggle source
@return [Boolean]
# File lib/procon_bypass_man/configuration/validator.rb, line 22 def invalid? !valid? end
valid?()
click to toggle source
@return [Boolean]
# File lib/procon_bypass_man/configuration/validator.rb, line 10 def valid? @errors = Hash.new {|h,k| h[k] = [] } validate_require_prefix_keys validate_config_of_button_lonely validate_verify_button_existence validate_flip_and_remap_are_hate_each_other @errors.empty? end
Private Instance Methods
validate_flip_and_remap_are_hate_each_other()
click to toggle source
# File lib/procon_bypass_man/configuration/validator.rb, line 78 def validate_flip_and_remap_are_hate_each_other @layers.each do |layer_key, value| flip_buttons = [] remap_buttons = [] value.flips.keys.map(&:to_sym).each { |b| flip_buttons << b } value.remaps.keys.map(&:to_sym).each { |b| remap_buttons << b } if(duplicated_buttons = flip_buttons & remap_buttons).length > 0 @errors[:layers] << "レイヤー#{layer_key}で、連打とリマップの定義が重複しているボタン#{duplicated_buttons.join(", ")}があります" end end end
validate_require_prefix_keys()
click to toggle source
# File lib/procon_bypass_man/configuration/validator.rb, line 45 def validate_require_prefix_keys if @prefix_keys.empty? @errors[:prefix_keys] ||= [] @errors[:prefix_keys] << "prefix_keys_for_changing_layerに値が入っていません。" end end