Class: MARC::ScoreRecord
- 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
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ ScoreRecord
constructor
A new instance of ScoreRecord.
- #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 ⇒ ScoreRecord
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
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
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 |