Class: Catalog::Nomenclature::EntryItem

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

Instance Method Summary collapse

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