Class: MARC::Record
- Inherits:
-
Object
show all
- Defined in:
- lib/enhanced_marc/record.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Record
Creates a new MARC::Record using MARC::Leader to work with the leader, rather than a string
8
9
10
11
12
|
# File 'lib/enhanced_marc/record.rb', line 8
def initialize
@fields = FieldMap.new
@leader = Leader.new(' ' * 24)
end
|
Instance Attribute Details
#bibliographic_level ⇒ Object
Returns the value of attribute bibliographic_level.
4
5
6
|
# File 'lib/enhanced_marc/record.rb', line 4
def bibliographic_level
@bibliographic_level
end
|
#record_type ⇒ Object
Returns the value of attribute record_type.
4
5
6
|
# File 'lib/enhanced_marc/record.rb', line 4
def record_type
@record_type
end
|
Class Method Details
.new_from_record(record) ⇒ Object
Instance Method Details
50
51
|
# File 'lib/enhanced_marc/record.rb', line 50
def composition_form(human_readable=false)
end
|
#contains_type?(record_type) ⇒ Boolean
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/enhanced_marc/record.rb', line 14
def contains_type?(record_type)
type_map = {"BKS"=>/[at]{1}/, "COM"=>"m", "MAP"=>/[ef]{1}/,"MIX"=>"p", "SCO"=>/[cd]{1}/, "REC"=>/[ij]{1}/, "SER"=>"s", "VIS"=>/[gkor]{1}/}
matching_fields = []
@fields.each_by_tag('006').each { | fxd_fld |
matching_fields << fxd_fld if fxd_fld.value[0,1].match(type_map[record_type])
}
return nil if matching_fields.empty?
return matching_fields
end
|
#created_on ⇒ Object
63
64
65
66
67
68
69
|
# File 'lib/enhanced_marc/record.rb', line 63
def created_on
unless self['008'].value[0,6] == (' '*6)
return Date.parse(self['008'].value[0,2]+'-'+self['008'].value[2,2]+'-'+self['008'].value[4,2], false)
else
return Date.today
end
end
|
#get_dates ⇒ Object
59
60
61
|
# File 'lib/enhanced_marc/record.rb', line 59
def get_dates
end
|
#inspect_fixed_fields ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/enhanced_marc/record.rb', line 71
def inspect_fixed_fields
type_map = {/[at]{1}/=>BookType,'m'=>ComputerType,/[ef]{1}/=>MapType,
'p'=>MixedType,/[cd]{1}/=>ScoreType,/[ij]{1}/=>SoundType,'s'=>SerialType,
/[gkor]{1}/=>VisualType}
@fields.each_by_tag('006').each { | fxd_fld |
type_map.each_key { | key |
if fxd_fld.value[0,1].match(key)
self.extend type_map[key]
end
}
}
end
|
#is_archival? ⇒ Boolean
45
46
47
|
# File 'lib/enhanced_marc/record.rb', line 45
def is_archival?
return @leader.is_archival?
end
|
#languages ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/enhanced_marc/record.rb', line 84
def languages
languages = []
unless self['008'].value[35,3].empty?
language = Locale::Info.get_language(self['008'].value[35,3])
languages << language if language
end
@fields.each_by_tag("041") do | oh_four_one |
langs = oh_four_one.find_all { |sub| sub.code == 'a'}
langs.each do | lang |
i = 0
while (i + 3) <= lang.value.length
language = Locale::Info.get_language(lang.value[i,3])
languages << language if language
i += 3
end
end
end
languages.uniq
end
|
#publication_country ⇒ Object
54
55
56
57
|
# File 'lib/enhanced_marc/record.rb', line 54
def publication_country
return self['008'].value[15,3].strip unless self['008'].value[15,3] == ' '
return false
end
|
#to_typed_record ⇒ Object
41
42
43
|
# File 'lib/enhanced_marc/record.rb', line 41
def to_typed_record
return self.new_from_record(self)
end
|