Class: Jobshop::Inspection::BooleanCriterion
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Jobshop::Inspection::BooleanCriterion
- Defined in:
- app/models/jobshop/inspection/boolean_criterion.rb
Instance Method Summary collapse
- #criterion_with_build ⇒ Object (also: #criterion)
- #pass?(value) ⇒ Boolean
-
#random ⇒ Object
Generate a random value that has a 90% chance of being in spec.
- #specification ⇒ Object
- #tolerance ⇒ Object
- #unit ⇒ Object
Instance Method Details
#criterion_with_build ⇒ Object Also known as: criterion
16 17 18 |
# File 'app/models/jobshop/inspection/boolean_criterion.rb', line 16 def criterion_with_build criterion_without_build || build_criterion(criterion_id: criterion_id, report: report) end |
#pass?(value) ⇒ Boolean
34 35 36 |
# File 'app/models/jobshop/inspection/boolean_criterion.rb', line 34 def pass?(value) ![ false, 0, "0", "f", "F", "false", "FALSE", "off", "OFF" ].include?(value) end |
#random ⇒ Object
Generate a random value that has a 90% chance of being in spec. TODO: This needs to go in the tests somewhere, not really in the model.
40 41 42 |
# File 'app/models/jobshop/inspection/boolean_criterion.rb', line 40 def random rand(100) < 10 end |
#specification ⇒ Object
22 23 24 |
# File 'app/models/jobshop/inspection/boolean_criterion.rb', line 22 def specification @specification ||= "#{condition}\nPASS/FAIL" end |
#tolerance ⇒ Object
26 27 28 |
# File 'app/models/jobshop/inspection/boolean_criterion.rb', line 26 def tolerance @tolerance ||= condition end |
#unit ⇒ Object
30 31 32 |
# File 'app/models/jobshop/inspection/boolean_criterion.rb', line 30 def unit "boolean".freeze end |