Class: BerkeleyLibrary::AV::Metadata
- Inherits:
-
Object
- Object
- BerkeleyLibrary::AV::Metadata
show all
- Includes:
- Constants
- Defined in:
- lib/berkeley_library/av/metadata.rb,
lib/berkeley_library/av/metadata/link.rb,
lib/berkeley_library/av/metadata/field.rb,
lib/berkeley_library/av/metadata/value.rb,
lib/berkeley_library/av/metadata/fields.rb,
lib/berkeley_library/av/metadata/source.rb,
lib/berkeley_library/av/metadata/readers/alma.rb,
lib/berkeley_library/av/metadata/readers/base.rb,
lib/berkeley_library/av/metadata/readers/tind.rb
Defined Under Namespace
Modules: Fields, Readers
Classes: Field, Link, Source, Value
Constant Summary
Constants included
from Constants
Constants::ALMA_RECORD_RE, Constants::MILLENNIUM_RECORD_RE, Constants::OCLC_RECORD_RE, Constants::SUBFIELD_CODES_TRACKS, Constants::SUBFIELD_CODE_ALMA_BIB_NUMBER, Constants::SUBFIELD_CODE_DURATION, Constants::SUBFIELD_CODE_LINKTEXT, Constants::SUBFIELD_CODE_PATH, Constants::SUBFIELD_CODE_TIND_BIB_NUMBER, Constants::SUBFIELD_CODE_TITLE, Constants::SUBFIELD_CODE_URI, Constants::TAG_ALMA_MIGRATION_INFO, Constants::TAG_LINK_FIELD, Constants::TAG_TIND_CATALOG_ID, Constants::TAG_TIND_ID, Constants::TAG_TITLE_FIELD, Constants::TAG_TRACK_FIELD, Constants::TAG_TRANSCRIPT_FIELD, Constants::UNKNOWN_TITLE
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(record_id:, source:, marc_record: nil) ⇒ Metadata
TODO: can we stop passing in record ID / stop lazy-loading MARC?
14
15
16
17
18
|
# File 'lib/berkeley_library/av/metadata.rb', line 14
def initialize(record_id:, source:, marc_record: nil)
@record_id = record_id
@source = source
@marc_record = marc_record
end
|
Instance Attribute Details
#record_id ⇒ Object
Returns the value of attribute record_id.
11
12
13
|
# File 'lib/berkeley_library/av/metadata.rb', line 11
def record_id
@record_id
end
|
#source ⇒ Object
Returns the value of attribute source.
11
12
13
|
# File 'lib/berkeley_library/av/metadata.rb', line 11
def source
@source
end
|
Class Method Details
.for_record(record_id:) ⇒ Object
67
68
69
70
71
72
|
# File 'lib/berkeley_library/av/metadata.rb', line 67
def for_record(record_id:)
source = Source.for_record_id(record_id)
raise AV::RecordNotFound, "Unable to determine metadata source for record ID: #{record_id.inspect}" unless source
Metadata.new(record_id:, source:)
end
|
Instance Method Details
#alma_id ⇒ Object
30
31
32
|
# File 'lib/berkeley_library/av/metadata.rb', line 30
def alma_id
id_001 if source == Source::ALMA
end
|
#bib_number ⇒ Object
20
21
22
23
24
|
# File 'lib/berkeley_library/av/metadata.rb', line 20
def bib_number
return @bib_number if instance_variable_defined?(:@bib_number)
@bib_number = source.find_bib_number(self)
end
|
#calnet_only? ⇒ Boolean
58
59
60
|
# File 'lib/berkeley_library/av/metadata.rb', line 58
def calnet_only?
restrictions.calnet_only?
end
|
#calnet_or_ip? ⇒ Boolean
54
55
56
|
# File 'lib/berkeley_library/av/metadata.rb', line 54
def calnet_or_ip?
restrictions.calnet_or_ip?
end
|
#description ⇒ Object
50
51
52
|
# File 'lib/berkeley_library/av/metadata.rb', line 50
def description
@description ||= (desc_value = values_by_field[Fields::DESCRIPTION]) ? desc_value.as_string : ''
end
|
#display_uri ⇒ Object
62
63
64
|
# File 'lib/berkeley_library/av/metadata.rb', line 62
def display_uri
@display_uri ||= source.display_uri_for(self)
end
|
#each_value ⇒ Object
42
43
44
|
# File 'lib/berkeley_library/av/metadata.rb', line 42
def each_value(&)
values_by_field.each_value(&)
end
|
#marc_record ⇒ Object
34
35
36
|
# File 'lib/berkeley_library/av/metadata.rb', line 34
def marc_record
@marc_record ||= source.record_for(record_id)
end
|
#tind_id ⇒ Object
26
27
28
|
# File 'lib/berkeley_library/av/metadata.rb', line 26
def tind_id
id_001 if source == Source::TIND
end
|
#title ⇒ Object
46
47
48
|
# File 'lib/berkeley_library/av/metadata.rb', line 46
def title
@title ||= (title_value = values_by_field[Fields::TITLE]) ? title_value.entries.first : UNKNOWN_TITLE
end
|
#values_by_field ⇒ Object
38
39
40
|
# File 'lib/berkeley_library/av/metadata.rb', line 38
def values_by_field
@values_by_field ||= Fields.default_values_from(marc_record).tap { |values| ensure_catalog_link(values) }
end
|