Class: MarkdownLint::Style
- Inherits:
-
Object
- Object
- MarkdownLint::Style
- Defined in:
- lib/mdl/style.rb
Instance Attribute Summary collapse
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
Class Method Summary collapse
Instance Method Summary collapse
- #all ⇒ Object
- #exclude_rule(id) ⇒ Object
- #exclude_tag(t) ⇒ Object
-
#initialize(all_rules) ⇒ Style
constructor
A new instance of Style.
- #rule(id, params = {}) ⇒ Object
- #tag(t) ⇒ Object
Constructor Details
#initialize(all_rules) ⇒ Style
Returns a new instance of Style.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/mdl/style.rb', line 7 def initialize(all_rules) @tagged_rules = {} all_rules.each do |id, r| r..each do |t| @tagged_rules[t] ||= Set.new @tagged_rules[t] << id end end @all_rules = all_rules @rules = Set.new end |
Instance Attribute Details
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
5 6 7 |
# File 'lib/mdl/style.rb', line 5 def rules @rules end |
Class Method Details
.load(style_file, rules) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/mdl/style.rb', line 40 def self.load(style_file, rules) unless style_file.include?("/") or style_file.end_with?(".rb") style_file = File.("../styles/#{style_file}.rb", __FILE__) end style = new(rules) style.instance_eval(File.read(style_file), style_file) rules.select! {|r| style.rules.include?(r)} style end |
Instance Method Details
#all ⇒ Object
19 20 21 |
# File 'lib/mdl/style.rb', line 19 def all @rules.merge(@all_rules.keys) end |
#exclude_rule(id) ⇒ Object
28 29 30 |
# File 'lib/mdl/style.rb', line 28 def exclude_rule(id) @rules.delete(id) end |
#exclude_tag(t) ⇒ Object
36 37 38 |
# File 'lib/mdl/style.rb', line 36 def exclude_tag(t) @rules.subtract(@tagged_rules[t]) end |
#rule(id, params = {}) ⇒ Object
23 24 25 26 |
# File 'lib/mdl/style.rb', line 23 def rule(id, params={}) @rules << id @all_rules[id].params(params) end |
#tag(t) ⇒ Object
32 33 34 |
# File 'lib/mdl/style.rb', line 32 def tag(t) @rules.merge(@tagged_rules[t]) end |