Class: RMARC::Leader
- Inherits:
-
Object
- Object
- RMARC::Leader
- Defined in:
- lib/rmarc/model/leader.rb
Overview
This class represents a leader or record label in a MARC record.
Instance Attribute Summary collapse
-
#base_address ⇒ Object
Returns the value of attribute base_address.
-
#char_coding ⇒ Object
Returns the value of attribute char_coding.
-
#entry_map ⇒ Object
Returns the value of attribute entry_map.
-
#impl_defined1 ⇒ Object
Returns the value of attribute impl_defined1.
-
#impl_defined2 ⇒ Object
Returns the value of attribute impl_defined2.
-
#indicator_count ⇒ Object
Returns the value of attribute indicator_count.
-
#record_length ⇒ Object
Returns the value of attribute record_length.
-
#record_status ⇒ Object
Returns the value of attribute record_status.
-
#record_type ⇒ Object
Returns the value of attribute record_type.
-
#subfield_code_length ⇒ Object
Returns the value of attribute subfield_code_length.
Instance Method Summary collapse
-
#initialize(ldr = nil) ⇒ Leader
constructor
A new instance of Leader.
-
#to_s ⇒ Object
Returns a string representation for a leader.
Constructor Details
#initialize(ldr = nil) ⇒ Leader
Returns a new instance of Leader.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rmarc/model/leader.rb', line 30 def initialize(ldr = nil) if (ldr == nil) @record_length = 0 @record_status = "n" @record_type = "a" @impl_defined1 = "m " @char_coding = " " @indicator_count = "2" @subfield_code_length = "2" @base_address = 0 @impl_defined2 = "a " @entry_map = "4500" else @record_length = ldr[0,5].to_i @record_status = ldr[5].chr @record_type = ldr[6].chr @impl_defined1 = ldr[7,2].to_s @char_coding = ldr[9].chr @indicator_count = ldr[10].chr @subfield_code_length = ldr[11].chr @base_address = ldr[12,5].to_i @impl_defined2 = ldr[17,3].to_s @entry_map = ldr[20,4].to_s end end |
Instance Attribute Details
#base_address ⇒ Object
Returns the value of attribute base_address.
28 29 30 |
# File 'lib/rmarc/model/leader.rb', line 28 def base_address @base_address end |
#char_coding ⇒ Object
Returns the value of attribute char_coding.
28 29 30 |
# File 'lib/rmarc/model/leader.rb', line 28 def char_coding @char_coding end |
#entry_map ⇒ Object
Returns the value of attribute entry_map.
28 29 30 |
# File 'lib/rmarc/model/leader.rb', line 28 def entry_map @entry_map end |
#impl_defined1 ⇒ Object
Returns the value of attribute impl_defined1.
28 29 30 |
# File 'lib/rmarc/model/leader.rb', line 28 def impl_defined1 @impl_defined1 end |
#impl_defined2 ⇒ Object
Returns the value of attribute impl_defined2.
28 29 30 |
# File 'lib/rmarc/model/leader.rb', line 28 def impl_defined2 @impl_defined2 end |
#indicator_count ⇒ Object
Returns the value of attribute indicator_count.
28 29 30 |
# File 'lib/rmarc/model/leader.rb', line 28 def indicator_count @indicator_count end |
#record_length ⇒ Object
Returns the value of attribute record_length.
28 29 30 |
# File 'lib/rmarc/model/leader.rb', line 28 def record_length @record_length end |
#record_status ⇒ Object
Returns the value of attribute record_status.
28 29 30 |
# File 'lib/rmarc/model/leader.rb', line 28 def record_status @record_status end |
#record_type ⇒ Object
Returns the value of attribute record_type.
28 29 30 |
# File 'lib/rmarc/model/leader.rb', line 28 def record_type @record_type end |
#subfield_code_length ⇒ Object
Returns the value of attribute subfield_code_length.
28 29 30 |
# File 'lib/rmarc/model/leader.rb', line 28 def subfield_code_length @subfield_code_length end |
Instance Method Details
#to_s ⇒ Object
Returns a string representation for a leader.
Example:
00714cam a2200205 a 4500
61 62 63 64 65 66 |
# File 'lib/rmarc/model/leader.rb', line 61 def to_s "%05d" % @record_length + "#@record_status#@record_type#@impl_defined1#@char_coding" + "#@indicator_count#@subfield_code_length" + "%05d" % @base_address + "#@impl_defined2#@entry_map" end |