Module: Inspectable

Extended by:
ActiveSupport::Concern
Included in:
InspectionCalibration, InspectionPoint
Defined in:
app/models/concerns/inspectable.rb

Instance Method Summary collapse

Instance Method Details

#maximal_sizeObject


25
26
27
# File 'app/models/concerns/inspectable.rb', line 25

def maximal_size
  (maximal_size_value || 0).in(grading_sizes_unit)
end

#minimal_sizeObject


21
22
23
# File 'app/models/concerns/inspectable.rb', line 21

def minimal_size
  (minimal_size_value || 0).in(grading_sizes_unit)
end

#net_massObject


17
18
19
# File 'app/models/concerns/inspectable.rb', line 17

def net_mass
  (net_mass_value || 0).in(grading_net_mass_unit)
end

#net_mass_yieldObject


33
34
35
36
37
38
# File 'app/models/concerns/inspectable.rb', line 33

def net_mass_yield
  unit_name = "#{grading_net_mass_unit.name}_per_#{product_net_surface_area.unit}"
  unit_name = :kilogram_per_hectare unless Nomen::Unit.find(unit_name)
  y = (net_mass.to_d(:kilogram) / sampling_area.to_d(:square_meter)).in(:kilogram_per_square_meter)
  y.in(unit_name).round(0)
end

#total_net_massObject


29
30
31
# File 'app/models/concerns/inspectable.rb', line 29

def total_net_mass
  (net_mass * (product_net_surface_area.to_d(:square_meter) / sampling_area.to_d(:square_meter))).round(0)
end