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

Returns a new instance of Checker.



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
35
36
37
38
39
40
# File 'lib/prism_checker/checker.rb', line 19

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

  walk_through do |node|
    node.check
  end

  @result = true
rescue Node::CheckFail
  # puts report
  @result = false
  # rescue Node::BadExpectation => e
  #   # raise
  #   raise e.class, report + "\n" + e.message
rescue StandardError => e
  # puts '---------------------'
  # puts e.class
  # puts e.message
  # pp e.backtrace
  # puts '---------------------'
  raise e.class, report + "\n" + e.message
end

#reportObject



42
43
44
# File 'lib/prism_checker/checker.rb', line 42

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