Class: PrismChecker::Checker

Inherits:
Object
  • Object
show all
Defined in:
lib/prism_checker/checker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChecker



12
13
14
15
16
17
# File 'lib/prism_checker/checker.rb', line 12

def initialize
  @item = nil
  @expectation = nil
  @root = nil
  @result = nil
end

Instance Attribute Details

#itemObject (readonly)

Returns the value of attribute item.



10
11
12
# File 'lib/prism_checker/checker.rb', line 10

def item
  @item
end

#resultObject (readonly)

Returns the value of attribute result.



10
11
12
# File 'lib/prism_checker/checker.rb', line 10

def result
  @result
end

#rootObject (readonly)

Returns the value of attribute root.



10
11
12
# File 'lib/prism_checker/checker.rb', line 10

def root
  @root
end

Instance Method Details

#check(item, expectation) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/prism_checker/checker.rb', line 19

def check(item, expectation)
  prepare(item, expectation)

  # rubocop:disable Style/SymbolProc
  # rubocop is wrong
  walk_through do |node|
    node.check
  end
  # rubocop:enable Style/SymbolProc

  @result = true
rescue Node::CheckFail
  @result = false
rescue StandardError => e
  raise e.class, "#{report}\n#{e.message}"
end

#reportObject



36
37
38
# File 'lib/prism_checker/checker.rb', line 36

def report
  ReportBuilder.new(@root).build
end