Class: TaxonDetermination

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Housekeeping, Shared::Citable, Shared::HasRoles
Defined in:
app/models/taxon_determination.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Housekeeping

#has_polymorphic_relationship?

Instance Attribute Details

#biological_collection_objectBiologicalCollectionObject

The object being determined.

Returns:

  • (BiologicalCollectionObject)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/models/taxon_determination.rb', line 19

class TaxonDetermination < ActiveRecord::Base
  acts_as_list scope: [:biological_collection_object_id]

  include Housekeeping
  include Shared::HasRoles
  include Shared::Citable

  belongs_to :otu
  belongs_to :biological_collection_object

  has_one :determiner_role, class_name: 'Determiner', as: :role_object
  has_one :determiner, through: :determiner_role, source: :person

  # TODO: factor these out (see also TaxonDetermination, Source::Bibtex)
  validates_numericality_of :year_made,
    only_integer: true, greater_than: 0,
    less_than_or_equal_to: Time.now.year,
    allow_nil: true,
    message: 'year made must be an integer greater than 0'
  validates_inclusion_of :month_made,
    in: 1..12, 
    allow_nil: true,
    message: ' month made'
  validates_numericality_of :day_made,
    allow_nil: true,
    only_integer: true,
    greater_than: 0,
    less_than_or_equal_to: Proc.new { |a| Time.utc(a.year_made, a.month_made).end_of_month.day },
    :unless => 'year_made.nil? || month_made.nil?',
    message: '%{value} is not a valid day_made for the month provided'

  def sort_date
    Utilities::Dates.nomenclature_date(day_made, month_made, year_made)
  end

  before_save :set_made_fields_if_not_provided

  protected

  def set_made_fields_if_not_provided
    if self.year_made.blank? && self.month_made.blank? && self.day_made.blank?
      self.year_made = Time.now.year 
      self.month_made = Time.now.month
      self.day_made = Time.now.day
    end
  end

end

#day_madeString

the day of the month the determination was made

Returns:

  • (String)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/models/taxon_determination.rb', line 19

class TaxonDetermination < ActiveRecord::Base
  acts_as_list scope: [:biological_collection_object_id]

  include Housekeeping
  include Shared::HasRoles
  include Shared::Citable

  belongs_to :otu
  belongs_to :biological_collection_object

  has_one :determiner_role, class_name: 'Determiner', as: :role_object
  has_one :determiner, through: :determiner_role, source: :person

  # TODO: factor these out (see also TaxonDetermination, Source::Bibtex)
  validates_numericality_of :year_made,
    only_integer: true, greater_than: 0,
    less_than_or_equal_to: Time.now.year,
    allow_nil: true,
    message: 'year made must be an integer greater than 0'
  validates_inclusion_of :month_made,
    in: 1..12, 
    allow_nil: true,
    message: ' month made'
  validates_numericality_of :day_made,
    allow_nil: true,
    only_integer: true,
    greater_than: 0,
    less_than_or_equal_to: Proc.new { |a| Time.utc(a.year_made, a.month_made).end_of_month.day },
    :unless => 'year_made.nil? || month_made.nil?',
    message: '%{value} is not a valid day_made for the month provided'

  def sort_date
    Utilities::Dates.nomenclature_date(day_made, month_made, year_made)
  end

  before_save :set_made_fields_if_not_provided

  protected

  def set_made_fields_if_not_provided
    if self.year_made.blank? && self.month_made.blank? && self.day_made.blank?
      self.year_made = Time.now.year 
      self.month_made = Time.now.month
      self.day_made = Time.now.day
    end
  end

end

#determinerPerson

the Person making the determination

Returns:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/models/taxon_determination.rb', line 19

class TaxonDetermination < ActiveRecord::Base
  acts_as_list scope: [:biological_collection_object_id]

  include Housekeeping
  include Shared::HasRoles
  include Shared::Citable

  belongs_to :otu
  belongs_to :biological_collection_object

  has_one :determiner_role, class_name: 'Determiner', as: :role_object
  has_one :determiner, through: :determiner_role, source: :person

  # TODO: factor these out (see also TaxonDetermination, Source::Bibtex)
  validates_numericality_of :year_made,
    only_integer: true, greater_than: 0,
    less_than_or_equal_to: Time.now.year,
    allow_nil: true,
    message: 'year made must be an integer greater than 0'
  validates_inclusion_of :month_made,
    in: 1..12, 
    allow_nil: true,
    message: ' month made'
  validates_numericality_of :day_made,
    allow_nil: true,
    only_integer: true,
    greater_than: 0,
    less_than_or_equal_to: Proc.new { |a| Time.utc(a.year_made, a.month_made).end_of_month.day },
    :unless => 'year_made.nil? || month_made.nil?',
    message: '%{value} is not a valid day_made for the month provided'

  def sort_date
    Utilities::Dates.nomenclature_date(day_made, month_made, year_made)
  end

  before_save :set_made_fields_if_not_provided

  protected

  def set_made_fields_if_not_provided
    if self.year_made.blank? && self.month_made.blank? && self.day_made.blank?
      self.year_made = Time.now.year 
      self.month_made = Time.now.month
      self.day_made = Time.now.day
    end
  end

end

#month_madeString

the month the determination was made. Literal values like Roman Numerals, abbreviations ('Jan.') etc. are allowed, but not all forms can be interpreted.

Returns:

  • (String)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/models/taxon_determination.rb', line 19

class TaxonDetermination < ActiveRecord::Base
  acts_as_list scope: [:biological_collection_object_id]

  include Housekeeping
  include Shared::HasRoles
  include Shared::Citable

  belongs_to :otu
  belongs_to :biological_collection_object

  has_one :determiner_role, class_name: 'Determiner', as: :role_object
  has_one :determiner, through: :determiner_role, source: :person

  # TODO: factor these out (see also TaxonDetermination, Source::Bibtex)
  validates_numericality_of :year_made,
    only_integer: true, greater_than: 0,
    less_than_or_equal_to: Time.now.year,
    allow_nil: true,
    message: 'year made must be an integer greater than 0'
  validates_inclusion_of :month_made,
    in: 1..12, 
    allow_nil: true,
    message: ' month made'
  validates_numericality_of :day_made,
    allow_nil: true,
    only_integer: true,
    greater_than: 0,
    less_than_or_equal_to: Proc.new { |a| Time.utc(a.year_made, a.month_made).end_of_month.day },
    :unless => 'year_made.nil? || month_made.nil?',
    message: '%{value} is not a valid day_made for the month provided'

  def sort_date
    Utilities::Dates.nomenclature_date(day_made, month_made, year_made)
  end

  before_save :set_made_fields_if_not_provided

  protected

  def set_made_fields_if_not_provided
    if self.year_made.blank? && self.month_made.blank? && self.day_made.blank?
      self.year_made = Time.now.year 
      self.month_made = Time.now.month
      self.day_made = Time.now.day
    end
  end

end

#otuOtu

the OTU (concept) of the determination

Returns:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/models/taxon_determination.rb', line 19

class TaxonDetermination < ActiveRecord::Base
  acts_as_list scope: [:biological_collection_object_id]

  include Housekeeping
  include Shared::HasRoles
  include Shared::Citable

  belongs_to :otu
  belongs_to :biological_collection_object

  has_one :determiner_role, class_name: 'Determiner', as: :role_object
  has_one :determiner, through: :determiner_role, source: :person

  # TODO: factor these out (see also TaxonDetermination, Source::Bibtex)
  validates_numericality_of :year_made,
    only_integer: true, greater_than: 0,
    less_than_or_equal_to: Time.now.year,
    allow_nil: true,
    message: 'year made must be an integer greater than 0'
  validates_inclusion_of :month_made,
    in: 1..12, 
    allow_nil: true,
    message: ' month made'
  validates_numericality_of :day_made,
    allow_nil: true,
    only_integer: true,
    greater_than: 0,
    less_than_or_equal_to: Proc.new { |a| Time.utc(a.year_made, a.month_made).end_of_month.day },
    :unless => 'year_made.nil? || month_made.nil?',
    message: '%{value} is not a valid day_made for the month provided'

  def sort_date
    Utilities::Dates.nomenclature_date(day_made, month_made, year_made)
  end

  before_save :set_made_fields_if_not_provided

  protected

  def set_made_fields_if_not_provided
    if self.year_made.blank? && self.month_made.blank? && self.day_made.blank?
      self.year_made = Time.now.year 
      self.month_made = Time.now.month
      self.day_made = Time.now.day
    end
  end

end

#year_madeString

the year the determination was made, abbreviations like '02' are allowed

Returns:

  • (String)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/models/taxon_determination.rb', line 19

class TaxonDetermination < ActiveRecord::Base
  acts_as_list scope: [:biological_collection_object_id]

  include Housekeeping
  include Shared::HasRoles
  include Shared::Citable

  belongs_to :otu
  belongs_to :biological_collection_object

  has_one :determiner_role, class_name: 'Determiner', as: :role_object
  has_one :determiner, through: :determiner_role, source: :person

  # TODO: factor these out (see also TaxonDetermination, Source::Bibtex)
  validates_numericality_of :year_made,
    only_integer: true, greater_than: 0,
    less_than_or_equal_to: Time.now.year,
    allow_nil: true,
    message: 'year made must be an integer greater than 0'
  validates_inclusion_of :month_made,
    in: 1..12, 
    allow_nil: true,
    message: ' month made'
  validates_numericality_of :day_made,
    allow_nil: true,
    only_integer: true,
    greater_than: 0,
    less_than_or_equal_to: Proc.new { |a| Time.utc(a.year_made, a.month_made).end_of_month.day },
    :unless => 'year_made.nil? || month_made.nil?',
    message: '%{value} is not a valid day_made for the month provided'

  def sort_date
    Utilities::Dates.nomenclature_date(day_made, month_made, year_made)
  end

  before_save :set_made_fields_if_not_provided

  protected

  def set_made_fields_if_not_provided
    if self.year_made.blank? && self.month_made.blank? && self.day_made.blank?
      self.year_made = Time.now.year 
      self.month_made = Time.now.month
      self.day_made = Time.now.day
    end
  end

end

Instance Method Details

#sort_dateObject



50
51
52
# File 'app/models/taxon_determination.rb', line 50

def sort_date
  Utilities::Dates.nomenclature_date(day_made, month_made, year_made)
end