Class: MARCSpec::LeaderSpec
- Inherits:
-
ControlFieldSpec
- Object
- ControlFieldSpec
- MARCSpec::LeaderSpec
- Defined in:
- lib/marcspec/leaderspec.rb
Overview
A LeaderSpec deals only with the leader. It's basically the same as a controlfield spec, but using the string 'LDR' to identify itself
Instance Attribute Summary
Attributes inherited from ControlFieldSpec
Instance Method Summary collapse
-
#initialize(tag, range = nil) ⇒ LeaderSpec
constructor
Built to be syntax-compatible with ControlFieldSpec, the tag must always be 'LDR' (case matters).
-
#marc_values(r) ⇒ String
Return the appropriate value (either the leader or a subset of it) from the given record.
Methods inherited from ControlFieldSpec
#==, #asDSLString, #asPPString, #char, fromPPString, #pretty_print
Constructor Details
#initialize(tag, range = nil) ⇒ LeaderSpec
Built to be syntax-compatible with ControlFieldSpec, the tag must always be 'LDR' (case matters)
instead of the whole leader.
16 17 18 19 20 21 22 |
# File 'lib/marcspec/leaderspec.rb', line 16 def initialize (tag, range=nil) unless tag == 'LDR' raise ArgumentError, "Tag must be 'LDR' for a LeaderSpec" end @tag = 'LDR' self.range = range end |
Instance Method Details
#marc_values(r) ⇒ String
Return the appropriate value (either the leader or a subset of it) from the given record
29 30 31 32 33 34 35 |
# File 'lib/marcspec/leaderspec.rb', line 29 def marc_values r if @range return r.leader[@range] else return r.leader end end |