Class: ProconBypassMan::ButtonsSettingConfiguration::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/procon_bypass_man/buttons_setting_configuration/validator.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Validator

Returns a new instance of Validator.



4
5
6
7
8
9
# File 'lib/procon_bypass_man/buttons_setting_configuration/validator.rb', line 4

def initialize(config)
  @macro_plugins = config.macro_registry.plugins
  @mode_plugins = config.mode_registry.plugins
  @layers = config.layers
  @prefix_keys = config.prefix_keys
end

Instance Method Details

#errorsHash

Returns:

  • (Hash)


31
32
33
# File 'lib/procon_bypass_man/buttons_setting_configuration/validator.rb', line 31

def errors
  @errors ||= Hash.new {|h,k| h[k] = [] }
end

#errors_to_sArray<String>

Returns:

  • (Array<String>)


36
37
38
39
40
41
42
43
# File 'lib/procon_bypass_man/buttons_setting_configuration/validator.rb', line 36

def errors_to_s
  errors.map { |_x, message|
    value = <<~EOH
      #{message.map { |m| "layer #{m}" }.join("\n")}
    EOH
    value.chomp
  }.join("\n")
end

#invalid?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/procon_bypass_man/buttons_setting_configuration/validator.rb', line 26

def invalid?
  !valid?
end

#valid?Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/procon_bypass_man/buttons_setting_configuration/validator.rb', line 12

def valid?
  @errors = Hash.new {|h,k| h[k] = [] }

  warn_blank_prefix_keys
  validate_config_of_button_lonely
  validate_verify_button_existence
  validate_flip_and_remap_are_hate_each_other
  validate_verify_mode_plugins
  validate_verify_macro_plugins

  @errors.empty?
end