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



17
18
19
# File 'app/models/jobshop/inspection/boolean_criterion.rb', line 17

def criterion
  super || build_criterion
end

#pass?(value) ⇒ Boolean

Returns:

  • (Boolean)


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

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. :nocov:



38
39
40
# File 'app/models/jobshop/inspection/boolean_criterion.rb', line 38

def random
  rand(100) < 10
end

#toleranceObject



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

def tolerance
  @tolerance ||= condition
end

#unitObject



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

def unit
  "boolean".freeze
end