Class: Catalog::Nomenclature::EntryItem

Inherits:
EntryItem
  • Object
show all
Defined in:
lib/catalog/nomenclature/entry_item.rb

Instance Attribute Summary

Attributes inherited from EntryItem

#base_object, #citation, #is_first, #is_last, #matches_current_target, #nomenclature_date, #object, #pages, #to_html_method, #year_suffix

Instance Method Summary collapse

Methods inherited from EntryItem

#base_data_attributes, #cited?, #cited_class, #in_source?, #object_class, #origin, #references_self?, #source, #topics

Constructor Details

#initialize(object: nil, base_object: nil, citation: nil, nomenclature_date: nil, year_suffix: nil, pages: nil, citation_date: nil, current_target: nil) ⇒ EntryItem

Returns a new instance of EntryItem.



3
4
5
6
# File 'lib/catalog/nomenclature/entry_item.rb', line 3

def initialize(object: nil, base_object: nil, citation: nil, nomenclature_date: nil, year_suffix: nil, pages: nil, citation_date: nil, current_target: nil)
  @matches_current_target = current_target
  super
end

Instance Method Details

#data_attributesObject



29
30
31
32
33
# File 'lib/catalog/nomenclature/entry_item.rb', line 29

def data_attributes
  base_data_attributes.merge(
    'history-is-valid' => is_valid_name?
  )
end

#from_relationship?Regex::Match

Returns:

  • (Regex::Match)


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

def from_relationship?
  object_class =~ /^TaxonNameRelationship/
end

#html_helperObject



8
9
10
# File 'lib/catalog/nomenclature/entry_item.rb', line 8

def html_helper
  :nomenclature_catalog_entry_item_tag
end

#is_valid_name?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/catalog/nomenclature/entry_item.rb', line 25

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

#other_nameString

Returns:

  • (String)


18
19
20
21
22
# File 'lib/catalog/nomenclature/entry_item.rb', line 18

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