Class: MARC::ScoreRecord

Inherits:
Record
  • Object
show all
Defined in:
lib/enhanced_marc/score_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

#initializeScoreRecord

Returns a new instance of ScoreRecord.



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

def initialize
  super
  @leader[6] = 'c' if @leader[6,1] == ' '
  @leader[7] = 'm' if @leader[7,1] == ' '    
  @record_type = 'SCO'  
  @bibliographic_level = @leader.get_blvl
  self.extend ScoreType      
  self.inspect_fixed_fields      
end

Class Method Details

.new_from_record(record) ⇒ Object



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

def self.new_from_record(record)
  rec = ScoreRecord.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
26
# File 'lib/enhanced_marc/score_record.rb', line 22

def is_valid_blvl?
  return true if @leader[7,1].match(/[acdim]{1}/) and @leader[6,1].match('d')
  return true if @leader[7,1].match(/[abcdims]{1}/) and @leader[6,1].match('c')
  return false
end

#is_valid_type?Boolean

Returns:

  • (Boolean)


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

def is_valid_type?
  return false unless @leader[6,1].match(/[cd]{1}/)
  return true
end