Class: Guideline::Visitor

Inherits:
Object
  • Object
show all
Defined in:
lib/guideline/visitor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern, checkers) ⇒ Visitor

Returns a new instance of Visitor.



7
8
9
10
# File 'lib/guideline/visitor.rb', line 7

def initialize(pattern, checkers)
  @pattern  = pattern
  @checkers = checkers
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/guideline/visitor.rb', line 5

def options
  @options
end

Instance Method Details

#errorsObject



28
29
30
# File 'lib/guideline/visitor.rb', line 28

def errors
  @errors ||= checkers.select(&:has_error?).map(&:errors).inject([], &:+)
end

#prepareObject



20
21
22
23
24
25
26
# File 'lib/guideline/visitor.rb', line 20

def prepare
  paths.each do |path|
    checkers.each do |checker|
      checker.prepare(path) if checker.respond_to?(:prepare)
    end
  end
end

#visitObject



12
13
14
15
16
17
18
# File 'lib/guideline/visitor.rb', line 12

def visit
  paths.each do |path|
    checkers.each do |checker|
      checker.check(path)
    end
  end
end