Class: MARC::MixedRecord
- Defined in:
- lib/enhanced_marc/mixed_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
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ MixedRecord
constructor
A new instance of MixedRecord.
- #is_valid_blvl? ⇒ Boolean
- #is_valid_type? ⇒ Boolean
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
#initialize ⇒ MixedRecord
Returns a new instance of MixedRecord.
8 9 10 11 12 13 14 15 16 |
# File 'lib/enhanced_marc/mixed_record.rb', line 8 def initialize super @leader[6] = 'p' if @leader[6,1] == ' ' @leader[7] = 'c' if @leader[7,1] == ' ' @record_type = 'MIX' @bibliographic_level = @leader.get_blvl self.extend MixedType 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/mixed_record.rb', line 26 def self.new_from_record(record) rec = MixedRecord.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
22 23 24 25 |
# File 'lib/enhanced_marc/mixed_record.rb', line 22 def is_valid_blvl? return false unless @leader[7,1].match(/[cdi]{1}/) return true end |
#is_valid_type? ⇒ Boolean
18 19 20 21 |
# File 'lib/enhanced_marc/mixed_record.rb', line 18 def is_valid_type? return false unless @leader[6,1].match('p') return true end |