Class: Jobshop::Inspection::BooleanCriterion

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

Instance Method Summary collapse

Instance Method Details

#criterion_with_buildObject 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

Returns:

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

#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.



40
41
42
# File 'app/models/jobshop/inspection/boolean_criterion.rb', line 40

def random
  rand(100) < 10
end

#specificationObject



22
23
24
# File 'app/models/jobshop/inspection/boolean_criterion.rb', line 22

def specification
  @specification ||= "#{condition}\nPASS/FAIL"
end

#toleranceObject



26
27
28
# File 'app/models/jobshop/inspection/boolean_criterion.rb', line 26

def tolerance
  @tolerance ||= condition
end

#unitObject



30
31
32
# File 'app/models/jobshop/inspection/boolean_criterion.rb', line 30

def unit
  "boolean".freeze
end