Class: MARC::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/enhanced_marc/record.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRecord

Creates a new MARC::Record using MARC::Leader to work with the leader, rather than a string



8
9
10
11
# File 'lib/enhanced_marc/record.rb', line 8

def initialize
  @fields = []
  @leader = Leader.new(' ' * 24) 
end

Instance Attribute Details

#bibliographic_levelObject (readonly)

Returns the value of attribute bibliographic_level.



4
5
6
# File 'lib/enhanced_marc/record.rb', line 4

def bibliographic_level
  @bibliographic_level
end

#record_typeObject (readonly)

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



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/enhanced_marc/record.rb', line 24

def self.new_from_record(record)
  leader = Leader.new(record.leader)
  case leader.get_type
    when 'BKS' then return MARC::BookRecord.new_from_record(record)
    when 'SER' then return MARC::SerialRecord.new_from_record(record)
    when 'VIS' then return MARC::VisualRecord.new_from_record(record)
    when 'MIX' then return MARC::MixedRecord.new_from_record(record)                
    when 'MAP' then return MARC::MapRecord.new_from_record(record)                
    when 'SCO' then return MARC::ScoreRecord.new_from_record(record)                
    when 'REC' then return MARC::SoundRecord.new_from_record(record)                
    when 'COM' then return MARC::ComputerRecord.new_from_record(record)                
  end      
end

Instance Method Details

#composition_form(human_readable = false) ⇒ Object



47
48
# File 'lib/enhanced_marc/record.rb', line 47

def composition_form(human_readable=false)
end

#contains_type?(record_type) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
22
# File 'lib/enhanced_marc/record.rb', line 13

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.find_all {|f| ('006') === f.tag}.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_onObject



60
61
62
63
64
65
66
# File 'lib/enhanced_marc/record.rb', line 60

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_datesObject



56
57
58
# File 'lib/enhanced_marc/record.rb', line 56

def get_dates

end

#inspect_fixed_fieldsObject



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/enhanced_marc/record.rb', line 68

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.find_all {|f| ('006') === f.tag}.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

Returns:

  • (Boolean)


42
43
44
# File 'lib/enhanced_marc/record.rb', line 42

def is_archival?
  return @leader.is_archival?
end

#publication_countryObject



51
52
53
54
# File 'lib/enhanced_marc/record.rb', line 51

def publication_country
  return self['008'].value[15,2] unless self['008'].value[15,2] == '  '
  return false
end

#to_typed_recordObject



38
39
40
# File 'lib/enhanced_marc/record.rb', line 38

def to_typed_record
  return self.new_from_record(self)
end