Class: MARC::SoundRecord
- Defined in:
- lib/enhanced_marc/sound_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 ⇒ SoundRecord
constructor
A new instance of SoundRecord.
- #valid_blvl? ⇒ Boolean (also: #is_valid_blvl?)
- #valid_type? ⇒ Boolean (also: #is_valid_type?)
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 ⇒ SoundRecord
Returns a new instance of SoundRecord.
8 9 10 11 12 13 14 15 16 |
# File 'lib/enhanced_marc/sound_record.rb', line 8 def initialize super @leader[6] = 'i' if @leader[6, 1] == ' ' @leader[7] = 'm' if @leader[7, 1] == ' ' @record_type = 'REC' @bibliographic_level = @leader.get_blvl extend SoundType 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/sound_record.rb', line 29 def self.new_from_record(record) rec = SoundRecord.new record.instance_variables.each { | var | rec.instance_variable_set(var, record.instance_variable_get(var)) } 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?
24 25 26 27 |
# File 'lib/enhanced_marc/sound_record.rb', line 24 def valid_blvl? return false unless @leader[7, 1] =~ /[abcdims]{1}/ true end |
#valid_type? ⇒ Boolean Also known as: is_valid_type?
18 19 20 21 |
# File 'lib/enhanced_marc/sound_record.rb', line 18 def valid_type? return false unless @leader[6, 1] =~ /[ij]{1}/ true end |