Class: CollectionObjectCatalog::EntryItem

Inherits:
Object
  • Object
show all
Defined in:
lib/collection_object_catalog/entry_item.rb

Overview

Is 1:1 with an event in the history of the object, as indexed by date (range)

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (EntryItem) initialize(object: nil, type: nil, start_date: nil, end_date: nil)

Returns a new instance of EntryItem

Raises:

  • (TaxonWorks::Error)


19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/collection_object_catalog/entry_item.rb', line 19

def initialize(object: nil, type: nil, start_date: nil, end_date: nil)
  raise TaxonWorks::Error, ':object is nil' if object.nil?
  raise TaxonWorks::Error, ':type is nil' if type.nil?
  raise TaxonWorks::Error, 'type is not in the list' if !CollectionObjectCatalog::EVENT_TYPES.include?(type)
  raise TaxonWorks::Error, 'start_date is not a DateTime' if start_date && !start_date.kind_of?(Time)
  raise TaxonWorks::Error, 'end_date is not a DateTime' if end_date && !end_date.kind_of?(Time)

  @object = object
  @start_date = start_date
  @type = type
  @end_date = end_date
end

Instance Attribute Details

- (Object) end_date

The latest point at which the event could have happened.



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

def end_date
  @end_date
end

- (Object) object

The base object from which this event is derived, required



7
8
9
# File 'lib/collection_object_catalog/entry_item.rb', line 7

def object
  @object
end

- (Object) start_date

The earliest point at which the event could have happened. If end_date is not provided assumed to be exact



14
15
16
# File 'lib/collection_object_catalog/entry_item.rb', line 14

def start_date
  @start_date
end

- (Object) type

Arbitrary categorization of event as per EVENT_TYPES, required



10
11
12
# File 'lib/collection_object_catalog/entry_item.rb', line 10

def type
  @type
end

Instance Method Details

- (Object) object_class_name



32
33
34
# File 'lib/collection_object_catalog/entry_item.rb', line 32

def object_class_name
  object.class.name
end