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

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

- (Object) citation

Optional



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

def citation
  @citation
end

- (None) citation_date

Returns:

  • (None)


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

def citation_date
  @citation_date
end

- (Date) nomenclature_date

Returns:

  • (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)


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

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

- (String) cited_class (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

- (Regex::Match) from_relationship?

Returns:

  • (Regex::Match)


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

def from_relationship?
  object_class =~ /^TaxonNameRelationship/
end

- (Boolean) is_subsequent?

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

- (Boolean) is_valid_name?

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

- (String) object_class

Returns:

  • (String)


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

def object_class
  object.class.name
end

- (String) origin

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

- (String) other_name

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

- (Source?) source

Returns:



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

def source
  citation.try(:source)
end