Class: NomenclatureCatalog::EntryItem
- Inherits:
-
Object
- Object
- NomenclatureCatalog::EntryItem
- Defined in:
- lib/nomenclature_catalog/entry_item.rb
Overview
Is 1:1 with a Citation
Instance Attribute Summary collapse
-
#citation ⇒ Object
Optional.
- #citation_date ⇒ None
- #nomenclature_date ⇒ Date
-
#object ⇒ Object
Returns the value of attribute object.
-
#taxon_name ⇒ Object
Required.
Instance Method Summary collapse
- #cited? ⇒ Boolean
- #cited_class ⇒ String protected
- #from_relationship? ⇒ Regex::Match
-
#initialize(object: nil, taxon_name: nil, citation: nil, nomenclature_date: nil, citation_date: nil) ⇒ EntryItem
constructor
A new instance of EntryItem.
- #is_subsequent? ⇒ Boolean
- #is_valid_name? ⇒ Boolean
- #object_class ⇒ String
- #origin ⇒ String
- #other_name ⇒ String
- #source ⇒ Source?
Constructor Details
#initialize(object: nil, taxon_name: nil, citation: nil, nomenclature_date: nil, citation_date: nil) ⇒ EntryItem
Returns a new instance of EntryItem.
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
#citation ⇒ Object
Optional
9 10 11 |
# File 'lib/nomenclature_catalog/entry_item.rb', line 9 def citation @citation end |
#citation_date ⇒ None
17 18 19 |
# File 'lib/nomenclature_catalog/entry_item.rb', line 17 def citation_date @citation_date end |
#nomenclature_date ⇒ Date
13 14 15 |
# File 'lib/nomenclature_catalog/entry_item.rb', line 13 def nomenclature_date @nomenclature_date end |
#object ⇒ Object
Returns the value of attribute object.
6 7 8 |
# File 'lib/nomenclature_catalog/entry_item.rb', line 6 def object @object end |
#taxon_name ⇒ Object
Required
20 21 22 |
# File 'lib/nomenclature_catalog/entry_item.rb', line 20 def taxon_name @taxon_name end |
Instance Method Details
#cited? ⇒ Boolean
35 36 37 |
# File 'lib/nomenclature_catalog/entry_item.rb', line 35 def cited? !citation.nil? # object.class.name == 'Citation' end |
#cited_class ⇒ String (protected)
101 102 103 104 105 106 107 |
# File 'lib/nomenclature_catalog/entry_item.rb', line 101 def cited_class if citation citation.annotated_object.class.name else object.class.name end end |
#from_relationship? ⇒ Regex::Match
59 60 61 |
# File 'lib/nomenclature_catalog/entry_item.rb', line 59 def from_relationship? object_class =~ /^TaxonNameRelationship/ end |
#is_subsequent? ⇒ Boolean
65 66 67 68 |
# File 'lib/nomenclature_catalog/entry_item.rb', line 65 def is_subsequent? # object == taxon_name && !citation.try(:is_original?) object == taxon_name && !citation.nil? && !citation.is_original? end |
#is_valid_name? ⇒ Boolean
94 95 96 |
# File 'lib/nomenclature_catalog/entry_item.rb', line 94 def is_valid_name? object_class == 'Protonym' && object.is_valid? end |
#object_class ⇒ String
54 55 56 |
# File 'lib/nomenclature_catalog/entry_item.rb', line 54 def object_class object.class.name end |
#origin ⇒ String
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/nomenclature_catalog/entry_item.rb', line 78 def origin case object_class when 'Protonym' 'protonym' when 'Hybrid' 'hybrid' when 'Combination' 'combination' when /TaxonNameRelationship/ 'taxon_name_relationship' else 'error' end end |
#other_name ⇒ String
71 72 73 74 75 |
# File 'lib/nomenclature_catalog/entry_item.rb', line 71 def other_name if from_relationship? ([object.subject_taxon_name, object.object_taxon_name] - [taxon_name]).first end end |
#source ⇒ Source?
40 41 42 |
# File 'lib/nomenclature_catalog/entry_item.rb', line 40 def source citation.try(:source) end |