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 ⇒ Object
- #pass?(value) ⇒ Boolean
-
#random ⇒ Object
Generate a random value that has a 90% chance of being in spec.
-
#tolerance ⇒ Object
def specification @specification ||= “#conditionnPASS/FAIL” end.
- #unit ⇒ Object
Instance Method Details
#criterion ⇒ Object
19 20 21 |
# File 'app/models/jobshop/inspection/boolean_criterion.rb', line 19 def criterion super || build_criterion end |
#pass?(value) ⇒ Boolean
37 38 39 |
# File 'app/models/jobshop/inspection/boolean_criterion.rb', line 37 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.
43 44 45 |
# File 'app/models/jobshop/inspection/boolean_criterion.rb', line 43 def random rand(100) < 10 end |
#tolerance ⇒ Object
def specification
@specification ||= "#{condition}\nPASS/FAIL"
end
29 30 31 |
# File 'app/models/jobshop/inspection/boolean_criterion.rb', line 29 def tolerance @tolerance ||= condition end |
#unit ⇒ Object
33 34 35 |
# File 'app/models/jobshop/inspection/boolean_criterion.rb', line 33 def unit "boolean".freeze end |