Class: MarkdownLint::RuleSet
- Inherits:
-
Object
- Object
- MarkdownLint::RuleSet
- Defined in:
- lib/mdl/ruleset.rb
Overview
defines a ruleset
Instance Attribute Summary collapse
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
Instance Method Summary collapse
- #docs(url = nil, &block) ⇒ Object
-
#initialize ⇒ RuleSet
constructor
A new instance of RuleSet.
- #load(rules_file) ⇒ Object
- #load_default ⇒ Object
- #rule(id, description, &block) ⇒ Object
Constructor Details
#initialize ⇒ RuleSet
Returns a new instance of RuleSet.
118 119 120 |
# File 'lib/mdl/ruleset.rb', line 118 def initialize @rules = {} end |
Instance Attribute Details
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
116 117 118 |
# File 'lib/mdl/ruleset.rb', line 116 def rules @rules end |
Instance Method Details
#docs(url = nil, &block) ⇒ Object
132 133 134 135 136 137 138 |
# File 'lib/mdl/ruleset.rb', line 132 def docs(url = nil, &block) if block_given? != url.nil? raise ArgumentError, 'Give either a URL or a block, not both' end @fallback_docs = block_given? ? block : lambda { |_, _| url } end |
#load(rules_file) ⇒ Object
127 128 129 130 |
# File 'lib/mdl/ruleset.rb', line 127 def load(rules_file) instance_eval(File.read(rules_file), rules_file) @rules end |
#load_default ⇒ Object
140 141 142 |
# File 'lib/mdl/ruleset.rb', line 140 def load_default load(File.('rules.rb', __dir__)) end |