Class: PrismChecker::Checker
- Inherits:
-
Object
- Object
- PrismChecker::Checker
- Defined in:
- lib/prism_checker/checker.rb
Instance Attribute Summary collapse
-
#item ⇒ Object
readonly
Returns the value of attribute item.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #check(item, expectation) ⇒ Object
-
#initialize ⇒ Checker
constructor
A new instance of Checker.
- #report ⇒ Object
Constructor Details
#initialize ⇒ Checker
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
#item ⇒ Object (readonly)
Returns the value of attribute item.
10 11 12 |
# File 'lib/prism_checker/checker.rb', line 10 def item @item end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
10 11 12 |
# File 'lib/prism_checker/checker.rb', line 10 def result @result end |
#root ⇒ Object (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. end |
#report ⇒ Object
42 43 44 |
# File 'lib/prism_checker/checker.rb', line 42 def report ReportBuilder.new(@root).build end |