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

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

Returns a new instance of EntryItem



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

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 == 'Protonym' || 'Combination' || 'TaxonNameRelationship')

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

Instance Attribute Details

- (Object) citation

Optional



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

def citation
  @citation
end

- (Object) citation_date

Date from the citation perspective (e.g. the date when the assertion in this entry was published) See also nomenclature_date



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

def citation_date
  @citation_date
end

- (Object) nomenclature_date

Date from the name perspective (e.g. sorted by original publication date) See also citation_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

- (Object) taxon_name

Required



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

def taxon_name
  @taxon_name
end

Instance Method Details

- (Boolean) cited?

Returns:

  • (Boolean)


33
34
35
# File 'lib/nomenclature_catalog/entry_item.rb', line 33

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

- (Object) cited_class (protected)



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

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

- (Boolean) from_relationship?

Returns:

  • (Boolean)


52
53
54
# File 'lib/nomenclature_catalog/entry_item.rb', line 52

def from_relationship?
  object_class =~ /^TaxonNameRelationship/
end

- (Boolean) is_subsequent?

Returns:

  • (Boolean)


56
57
58
# File 'lib/nomenclature_catalog/entry_item.rb', line 56

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

- (Object) object_class



48
49
50
# File 'lib/nomenclature_catalog/entry_item.rb', line 48

def object_class
  object.class.name
end

- (Object) other_name



60
61
62
63
64
# File 'lib/nomenclature_catalog/entry_item.rb', line 60

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

- (Object) source



37
38
39
# File 'lib/nomenclature_catalog/entry_item.rb', line 37

def source
  citation.try(:source)
end