Class: MARC::ComputerRecord
- Defined in:
- lib/enhanced_marc/computer_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
#bibliographic_level, #record_type
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ ComputerRecord
constructor
A new instance of ComputerRecord.
- #is_valid_blvl? ⇒ Boolean
- #is_valid_type? ⇒ Boolean
Methods inherited from Record
#composition_form, #contains_type?, #created_on, #get_dates, #inspect_fixed_fields, #is_archival?, #publication_country, #to_typed_record
Constructor Details
#initialize ⇒ ComputerRecord
Returns a new instance of ComputerRecord.
8 9 10 11 12 13 14 15 16 |
# File 'lib/enhanced_marc/computer_record.rb', line 8 def initialize super @leader[6] = 'm' if @leader[6,1] == ' ' @leader[7] = 'm' if @leader[7,1] == ' ' @record_type = 'COM' @bibliographic_level = @leader.get_blvl self.extend ComputerType 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/computer_record.rb', line 26 def self.new_from_record(record) rec = ComputerRecord.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/computer_record.rb', line 22 def is_valid_blvl? return false unless @leader[7,1].match(/[abcdims]{1}/) return true end |
#is_valid_type? ⇒ Boolean
18 19 20 21 |
# File 'lib/enhanced_marc/computer_record.rb', line 18 def is_valid_type? return false unless @leader[6,1].match('m') return true end |