Class: Observation::Sample

Inherits:
Observation show all
Defined in:
app/models/observation/sample.rb

Overview

See Descriptor::Sample

Instance Attribute Summary

Attributes inherited from Observation

#cached, #cached_column_label, #cached_row_label, #character_state_id, #continuous_unit, #continuous_value, #day_made, #descriptions, #descriptor_id, #frequency, #month_made, #observation_object_global_id, #observation_object_id, #observation_object_type, #presence, #project_id, #sample_max, #sample_mean, #sample_median, #sample_min, #sample_n, #sample_standard_deviation, #sample_standard_error, #sample_standard_units, #time_made, #type, #year_made

Instance Method Summary collapse

Methods inherited from Observation

by_matrix_and_position, by_observation_matrix_row, code_column, #continuous?, copy, destroy_column, destroy_row, human_name, in_observation_matrix, object_scope, #presence_absence?, #qualitative?, #type_matches_descriptor

Methods included from Shared::IsData

#errors_excepting, #full_error_messages_excepting, #identical, #is_community?, #is_destroyable?, #is_editable?, #is_in_use?, #is_in_users_projects?, #metamorphosize, #similar

Methods included from Shared::ProtocolRelationships

#protocolled?, #reject_protocols

Methods included from Shared::Confidences

#reject_confidences

Methods included from Shared::Depictions

#has_depictions?, #image_array=, #reject_depictions, #reject_images

Methods included from Shared::Tags

#reject_tags, #tag_with, #tagged?, #tagged_with?

Methods included from Shared::Notes

#concatenated_notes_string, #reject_notes

Methods included from Shared::Identifiers

#dwc_occurrence_id, #identified?, #next_by_identifier, #previous_by_identifier, #reject_identifiers, #uri, #uuid

Methods included from Shared::DataAttributes

#import_attributes, #internal_attributes, #keyword_value_hash, #reject_data_attributes

Methods included from Shared::Citations

#cited?, #mark_citations_for_destruction, #nomenclature_date, #origin_citation_source_id, #reject_citations, #requires_citation?, #sources_by_topic_id

Methods included from Housekeeping

#has_polymorphic_relationship?

Methods inherited from ApplicationRecord

transaction_with_retry

Instance Method Details

#median_between_min_maxObject (protected)



19
20
21
22
23
# File 'app/models/observation/sample.rb', line 19

def median_between_min_max
  if sample_min.present? && sample_max.present? && sample_median.present?
    errors.add(:sample_median, 'is not between min and max)') if !(sample_median <= sample_max) || !(sample_median >= sample_min)
  end
end

#valid_min_max_boundaryObject (protected)



14
15
16
17
# File 'app/models/observation/sample.rb', line 14

def valid_min_max_boundary
  errors.add(:sample_min, 'minimum is greater than maximum' ) if sample_min && sample_max && ( sample_min > sample_max )
  errors.add(:sample_max, 'maximum is less than minimum' ) if sample_min && sample_max && (sample_max < sample_min)
end

#valid_sample_meanObject (protected)



25
26
27
28
29
# File 'app/models/observation/sample.rb', line 25

def valid_sample_mean
  if sample_min.present? && sample_max.present? && sample_mean.present?
    errors.add(:sample_mean, 'is not between min and max)') if !(sample_mean <= sample_max) || !(sample_mean >= sample_min)
  end
end