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
#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
#bibliographic_level ⇒ Object
53
54
55
|
# File 'lib/enhanced_marc/record.rb', line 53
def bibliographic_level
@leader.get_blvl
end
|
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
66
67
68
69
70
71
72
|
# File 'lib/enhanced_marc/record.rb', line 66
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
62
63
64
|
# File 'lib/enhanced_marc/record.rb', line 62
def get_dates
end
|
#inspect_fixed_fields ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/enhanced_marc/record.rb', line 74
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/enhanced_marc/record.rb', line 87
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
57
58
59
60
|
# File 'lib/enhanced_marc/record.rb', line 57
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
|