Class: MARC::MapRecord
Overview
A class that represents an individual MARC record. Every record is made up of a collection of MARC::Field objects.
Instance Attribute Summary
Attributes inherited from Record
#record_type
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Record
#bibliographic_level, #composition_form, #contains_type?, #created_on, #get_dates, #inspect_fixed_fields, #is_archival?, #languages, #publication_country, #to_typed_record
Constructor Details
7
8
9
10
11
12
13
14
15
|
# File 'lib/enhanced_marc/map_record.rb', line 7
def initialize
super
@leader[6] = 'e' if @leader[6, 1] == ' '
@leader[7] = 'm' if @leader[7, 1] == ' '
@record_type = 'MAP'
@bibliographic_level = @leader.get_blvl
extend MapType
inspect_fixed_fields
end
|
Class Method Details
.new_from_record(record) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/enhanced_marc/map_record.rb', line 32
def self.new_from_record(record)
rec = MapRecord.new
record.instance_variables.each do |var|
rec.instance_variable_set(var, record.instance_variable_get(var))
end
error = rec.valid_type? ? nil : 'Incorrect type declaration in leader'
if !error && !rec.valid_blvl?
error = 'Incorrect bibliographic declaration in leader'
end
return Exception.new(error) if error
rec
end
|
Instance Method Details
#valid_blvl? ⇒ Boolean
Also known as:
is_valid_blvl?
22
23
24
25
26
27
28
29
30
|
# File 'lib/enhanced_marc/map_record.rb', line 22
def valid_blvl?
if @leader[7, 1] =~ /[acdim]{1}/ && @leader[6, 1] == 'f'
true
elsif @leader[7, 1] =~ /[abcdims]{1}/ && @leader[6, 1] == 'e'
true
else
false
end
end
|
#valid_type? ⇒ Boolean
Also known as:
is_valid_type?
17
18
19
20
|
# File 'lib/enhanced_marc/map_record.rb', line 17
def valid_type?
return false unless @leader[6, 1] =~ /[ef]{1}/
true
end
|