Class: MARC::ComputerRecord

Inherits:
Record
  • Object
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

#bibliographic_level, #record_type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Record

#composition_form, #contains_type?, #created_on, #get_dates, #inspect_fixed_fields, #is_archival?, #publication_country, #to_typed_record

Constructor Details

#initializeComputerRecord

Returns a new instance of ComputerRecord.



8
9
10
11
12
13
14
15
16
# File 'lib/enhanced_marc/computer_record.rb', line 8

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
  self.extend ComputerType      
  self.inspect_fixed_fields      
end

Class Method Details

.new_from_record(record) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/enhanced_marc/computer_record.rb', line 26

def self.new_from_record(record)
  rec = ComputerRecord.new
  record.instance_variables.each { | var |
    rec.instance_variable_set(var, record.instance_variable_get(var))
  }
  return Exception.new("Incorrect type declaration in leader") unless rec.is_valid_type?
  return Exception.new("Incorrect bibliographic declaration in leader") unless rec.is_valid_blvl?
  return rec
end

Instance Method Details

#is_valid_blvl?Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/enhanced_marc/computer_record.rb', line 22

def is_valid_blvl?
  return false unless @leader[7,1].match(/[abcdims]{1}/)
  return true
end

#is_valid_type?Boolean

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/enhanced_marc/computer_record.rb', line 18

def is_valid_type?
  return false unless @leader[6,1].match('m')
  return true
end