Class: YamlBot::RulesBot
- Inherits:
-
Object
- Object
- YamlBot::RulesBot
- Defined in:
- lib/yaml_bot/rules_bot.rb
Instance Attribute Summary collapse
-
#rules ⇒ Object
Returns the value of attribute rules.
Instance Method Summary collapse
-
#initialize(rules = nil) ⇒ RulesBot
constructor
A new instance of RulesBot.
- #validate_rules ⇒ Object
Constructor Details
#initialize(rules = nil) ⇒ RulesBot
Returns a new instance of RulesBot.
8 9 10 |
# File 'lib/yaml_bot/rules_bot.rb', line 8 def initialize(rules = nil) @rules = rules end |
Instance Attribute Details
#rules ⇒ Object
Returns the value of attribute rules.
6 7 8 |
# File 'lib/yaml_bot/rules_bot.rb', line 6 def rules @rules end |
Instance Method Details
#validate_rules ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/yaml_bot/rules_bot.rb', line 12 def validate_rules raise ValidationError, '.yamlbot rules file is not set.' if @rules.nil? raise ValidationError, 'rules section not defined in .yamlbot file' if @rules['rules'].nil? validate_rules_keys(@rules['defaults']) unless @rules['defaults'].nil? if @rules['rules'].instance_of?(Array) validate_each_key_rule else msg = "The rules section of a rules file must define a list of keys.\n" raise ValidationError, msg end end |