Class: MARC::VisualRecord
- Defined in:
- lib/enhanced_marc/visual_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 ⇒ VisualRecord
constructor
A new instance of VisualRecord.
- #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 ⇒ VisualRecord
Returns a new instance of VisualRecord.
7 8 9 10 11 12 13 14 15 |
# File 'lib/enhanced_marc/visual_record.rb', line 7 def initialize super @leader[6] = 'g' if @leader[6,1] == ' ' @leader[7] = 'm' if @leader[7,1] == ' ' @record_type = 'VIS' @bibliographic_level = @leader.get_blvl extend VisualType 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/visual_record.rb', line 29 def self.new_from_record(record) rec = VisualRecord.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?
23 24 25 26 |
# File 'lib/enhanced_marc/visual_record.rb', line 23 def valid_blvl? return false unless @leader[7, 1] =~ /[abcdims]{1}/ true end |
#valid_type? ⇒ Boolean Also known as: is_valid_type?
17 18 19 20 |
# File 'lib/enhanced_marc/visual_record.rb', line 17 def valid_type? return false unless @leader[6, 1] =~ /[gkro]{1}/ true end |