Class: Catalog::EntryItem
- Inherits:
-
Object
- Object
- Catalog::EntryItem
- Defined in:
- lib/catalog/entry_item.rb
Overview
A Catalog::EntryItem corresponds to a single row in the catalog. It can be thought of as a chronological entry typically 1:1 with some Citation.
Direct Known Subclasses
Distribution::EntryItem, Nomenclature::EntryItem, Otu::EntryItem
Instance Attribute Summary collapse
-
#base_object ⇒ Object
The visualized element of this entry item, e.g.
-
#citation ⇒ Object
Optional, should be provided explicitly.
-
#is_first ⇒ Boolean
See Catalog::Entry#first_item?.
-
#is_last ⇒ Boolean
See Catalog::Entry#last_item?.
-
#matches_current_target ⇒ Boolean
Does this match the target Entry.
-
#nomenclature_date ⇒ Date
!!TODO: we should not be checking at this point.
-
#object ⇒ Object
The source of this entry item, e.g.
-
#pages ⇒ String
Source.pages.
-
#to_html_method ⇒ Symbol
A pointer to a method in /app/helpers.
-
#year_suffix ⇒ String
Source.year_suffix.
Instance Method Summary collapse
- #base_data_attributes ⇒ Object
- #cited? ⇒ Boolean
- #cited_class ⇒ String protected
-
#data_attributes ⇒ Object
See Subclasses for extensions.
- #html_helper ⇒ Object
-
#in_source?(target_source) ⇒ Boolean
TODO: optimize indecies so this is not needed.
-
#initialize(object: nil, base_object: nil, citation: nil, nomenclature_date: nil, year_suffix: nil, pages: nil, citation_date: nil, current_target: nil) ⇒ EntryItem
constructor
A new instance of EntryItem.
-
#object_class ⇒ String
Do not update with base_class.
- #origin ⇒ String
- #references_self? ⇒ Boolean
- #source ⇒ Source?
-
#topics ⇒ Array of Topic
The topics on this object for this Citation/Source combination only.
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.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/catalog/entry_item.rb', line 51 def initialize(object: nil, base_object: nil, citation: nil, nomenclature_date: nil, year_suffix: nil, pages: nil, citation_date: nil, current_target: nil) raise if object.nil? @object = object @base_object = base_object @nomenclature_date = nomenclature_date @year_suffix = citation&.source&.year_suffix @pages = citation&.source&.pages @citation = citation @matches_current_target = current_target end |
Instance Attribute Details
#base_object ⇒ Object
The visualized element of this entry item, e.g. the subject taxon name of a taxon name relationship
5 6 7 |
# File 'lib/catalog/entry_item.rb', line 5 def base_object @base_object end |
#citation ⇒ Object
Optional, should be provided explicitly
11 12 13 |
# File 'lib/catalog/entry_item.rb', line 11 def citation @citation end |
#is_first ⇒ Boolean
Returns See Catalog::Entry#first_item?.
40 41 42 |
# File 'lib/catalog/entry_item.rb', line 40 def is_first @is_first end |
#is_last ⇒ Boolean
Returns See Catalog::Entry#last_item?.
44 45 46 |
# File 'lib/catalog/entry_item.rb', line 44 def is_last @is_last end |
#matches_current_target ⇒ Boolean
Returns does this match the target Entry.
48 49 50 |
# File 'lib/catalog/entry_item.rb', line 48 def matches_current_target @matches_current_target end |
#nomenclature_date ⇒ Date
!!TODO: we should not be checking at this point. Assignment must happen outside this module.
20 21 22 |
# File 'lib/catalog/entry_item.rb', line 20 def nomenclature_date @nomenclature_date end |
#object ⇒ Object
The source of this entry item, e.g. a TaxonNameRelationship
8 9 10 |
# File 'lib/catalog/entry_item.rb', line 8 def object @object end |
#pages ⇒ String
Source.pages
28 29 30 |
# File 'lib/catalog/entry_item.rb', line 28 def pages @pages end |
#to_html_method ⇒ Symbol
Returns a pointer to a method in /app/helpers.
32 33 34 |
# File 'lib/catalog/entry_item.rb', line 32 def to_html_method @to_html_method end |
#year_suffix ⇒ String
Source.year_suffix
24 25 26 |
# File 'lib/catalog/entry_item.rb', line 24 def year_suffix @year_suffix end |
Instance Method Details
#base_data_attributes ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/catalog/entry_item.rb', line 66 def base_data_attributes { 'history-origin' => origin, 'history-object-id' => object.to_global_id.to_s, 'history-year' => nomenclature_date&.year || 'unknown', 'history-is-first' => is_first, 'history-is-last' => is_last, 'history-is-cited' => (citation ? true : false), 'history-is-current-target' => matches_current_target } end |
#cited? ⇒ Boolean
88 89 90 |
# File 'lib/catalog/entry_item.rb', line 88 def cited? !citation.nil? # object.class.name == 'Citation' end |
#cited_class ⇒ String (protected)
145 146 147 148 149 150 151 |
# File 'lib/catalog/entry_item.rb', line 145 def cited_class if citation citation.annotated_object.class.name else object.class.name end end |
#data_attributes ⇒ Object
See Subclasses for extensions
83 84 85 |
# File 'lib/catalog/entry_item.rb', line 83 def data_attributes base_data_attributes end |
#html_helper ⇒ Object
62 63 64 |
# File 'lib/catalog/entry_item.rb', line 62 def html_helper :object_tag end |
#in_source?(target_source) ⇒ Boolean
TODO: optimize indecies so this is not needed.
138 139 140 |
# File 'lib/catalog/entry_item.rb', line 138 def in_source?(target_source) source == target_source end |
#object_class ⇒ String
Returns do not update with base_class.
113 114 115 |
# File 'lib/catalog/entry_item.rb', line 113 def object_class object.class.name end |
#origin ⇒ String
118 119 120 121 122 123 124 125 |
# File 'lib/catalog/entry_item.rb', line 118 def origin case object_class when /TaxonNameRelationship/ 'taxon_name_relationship' else object_class.tableize.singularize.humanize.downcase end end |
#references_self? ⇒ Boolean
78 79 80 |
# File 'lib/catalog/entry_item.rb', line 78 def references_self? object == base_object end |
#source ⇒ Source?
93 94 95 |
# File 'lib/catalog/entry_item.rb', line 93 def source citation&.source end |
#topics ⇒ Array of Topic
Returns the topics on this object for this Citation/Source combination only.
129 130 131 132 133 134 135 |
# File 'lib/catalog/entry_item.rb', line 129 def topics t = [] if source t += citation.topics end t.uniq end |