Class: Catalog::CollectionObject::EntryItem

Inherits:
Object
  • Object
show all
Defined in:
lib/catalog/collection_object/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

#initialize(object: nil, type: nil, start_date: nil, end_date: nil) ⇒ EntryItem

Returns a new instance of EntryItem.

Parameters:

  • args (Hash)

Raises:

  • (TaxonWorks::Error)


19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/catalog/collection_object/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 !Catalog::CollectionObject::EVENT_TYPES.include?(type)
  raise TaxonWorks::Error, 'start_date is not a Time' if start_date && !start_date.kind_of?(Time)
  raise TaxonWorks::Error, 'end_date is not a Time' if end_date && !end_date.kind_of?(Time)

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

Instance Attribute Details

#end_dateObject

The latest point at which the event could have happened.



16
17
18
# File 'lib/catalog/collection_object/entry_item.rb', line 16

def end_date
  @end_date
end

#objectObject

The base object from which this event is derived, required



5
6
7
# File 'lib/catalog/collection_object/entry_item.rb', line 5

def object
  @object
end

#start_dateObject

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



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

def start_date
  @start_date
end

#typeObject

Arbitrary categorization of event as per EVENT_TYPES, required TODO: this is a terrible method name



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

def type
  @type
end

Instance Method Details

#object_class_nameString

Returns:

  • (String)


33
34
35
# File 'lib/catalog/collection_object/entry_item.rb', line 33

def object_class_name
  object.class.name
end