Class: NomenclatureCatalog::EntryItem

Inherits:
Object
  • Object
show all
Defined in:
lib/nomenclature_catalog/entry_item.rb

Overview

Is 1:1 with a Citation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object: nil, taxon_name: nil, citation: nil, nomenclature_date: nil, citation_date: nil) ⇒ EntryItem

Returns a new instance of EntryItem

Parameters:

  • args (Hash)


23
24
25
26
27
28
29
30
31
32
# File 'lib/nomenclature_catalog/entry_item.rb', line 23

def initialize(object: nil, taxon_name: nil, citation: nil, nomenclature_date: nil, citation_date: nil)
  raise if object.nil? || taxon_name.nil?
  raise if nomenclature_date.nil? && !(object.class.to_s == 'Protonym' || 'Combination' || 'TaxonNameRelationship')

  @object = object
  @taxon_name = taxon_name
  @nomenclature_date = nomenclature_date
  @citation_date = citation_date
  @citation = citation
end

Instance Attribute Details

#citationObject

Optional



9
10
11
# File 'lib/nomenclature_catalog/entry_item.rb', line 9

def citation
  @citation
end

#citation_dateNone

Returns:

  • (None)


17
18
19
# File 'lib/nomenclature_catalog/entry_item.rb', line 17

def citation_date
  @citation_date
end

#nomenclature_dateDate

Returns:

  • (Date)


13
14
15
# File 'lib/nomenclature_catalog/entry_item.rb', line 13

def nomenclature_date
  @nomenclature_date
end

#objectObject

Returns the value of attribute object



6
7
8
# File 'lib/nomenclature_catalog/entry_item.rb', line 6

def object
  @object
end

#taxon_nameObject

Required



20
21
22
# File 'lib/nomenclature_catalog/entry_item.rb', line 20

def taxon_name
  @taxon_name
end

Instance Method Details

#cited?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/nomenclature_catalog/entry_item.rb', line 35

def cited?
  !citation.nil? # object.class.name == 'Citation'
end

#cited_classString (protected)

Returns:

  • (String)


100
101
102
103
104
105
106
# File 'lib/nomenclature_catalog/entry_item.rb', line 100

def cited_class
  if citation
    citation.annotated_object.class.name
  else
    object.class.name
  end
end

#from_relationship?Regex::Match

Returns:

  • (Regex::Match)


59
60
61
# File 'lib/nomenclature_catalog/entry_item.rb', line 59

def from_relationship?
  object_class =~ /^TaxonNameRelationship/
end

#is_subsequent?Boolean

Returns:

  • (Boolean)


64
65
66
67
# File 'lib/nomenclature_catalog/entry_item.rb', line 64

def is_subsequent?
 #     object == taxon_name && !citation.try(:is_original?)
  object == taxon_name && !citation.nil? && !citation.is_original?
end

#is_valid_name?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/nomenclature_catalog/entry_item.rb', line 93

def is_valid_name?
  object_class == 'Protonym' && object.is_valid?
end

#object_classString

Returns:

  • (String)


54
55
56
# File 'lib/nomenclature_catalog/entry_item.rb', line 54

def object_class
  object.class.name
end

#originString

Returns:

  • (String)


77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/nomenclature_catalog/entry_item.rb', line 77

def origin
  case object_class
  when 'Protonym'
    'protonym'
  when 'Hybrid'
    'hybrid'
  when 'Combination'
    'combination'
  when /TaxonNameRelationship/
    'taxon_name_relationship'
  else
    'error'
  end
end

#other_nameString

Returns:

  • (String)


70
71
72
73
74
# File 'lib/nomenclature_catalog/entry_item.rb', line 70

def other_name
  if from_relationship?
    ([object.subject_taxon_name, object.object_taxon_name] - [taxon_name]).first
  end
end

#sourceSource?

Returns:



40
41
42
# File 'lib/nomenclature_catalog/entry_item.rb', line 40

def source
  citation.try(:source)
end