Class: Jobshop::Inspection::BooleanCriterion

Inherits:
ApplicationRecord show all
Defined in:
app/models/jobshop/inspection/boolean_criterion.rb

Instance Method Summary collapse

Instance Method Details

#criterionObject



19
20
21
# File 'app/models/jobshop/inspection/boolean_criterion.rb', line 19

def criterion
  super || build_criterion
end

#pass?(value) ⇒ Boolean

Returns:

  • (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

#randomObject

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

#toleranceObject

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

#unitObject



33
34
35
# File 'app/models/jobshop/inspection/boolean_criterion.rb', line 33

def unit
  "boolean".freeze
end