Class: MARC::ComputerRecord
- Inherits:
-
Record
- Object
- Record
- MARC::ComputerRecord
show all
- Defined in:
- lib/enhanced_marc/computer_record.rb
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/computer_record.rb', line 7
def initialize
super
@leader[6] = 'm' if @leader[6,1] == ' '
@leader[7] = 'm' if @leader[7,1] == ' '
@record_type = 'COM'
@bibliographic_level = @leader.get_blvl
extend ComputerType
inspect_fixed_fields
end
|
Class Method Details
.new_from_record(record) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/enhanced_marc/computer_record.rb', line 29
def self.new_from_record(record)
rec = ComputerRecord.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?
23
24
25
26
|
# File 'lib/enhanced_marc/computer_record.rb', line 23
def valid_blvl?
return false unless @leader[7, 1] =~ /[abcdims]{1}/
true
end
|
#valid_type? ⇒ Boolean
Also known as:
is_valid_type?
17
18
19
20
|
# File 'lib/enhanced_marc/computer_record.rb', line 17
def valid_type?
return false unless @leader[6, 1] == 'm'
true
end
|