class MARCSpec::LeaderSpec
A LeaderSpec
deals only with the leader. It's basically the same as a controlfield spec, but using the string 'LDR' to identify itself
Public Class Methods
new(tag, range=nil)
click to toggle source
Built to be syntax-compatible with ControlFieldSpec
, the tag must always be 'LDR' (case matters)
@param ['LDR'] tag The 'tag'; in this case, always 'LDR' @param [Fixnum, Range<Fixnum>] range substring specification (either one character or a range) to return instead of the whole leader.
# 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
Public Instance Methods
marc_values(r)
click to toggle source
Return the appropriate value (either the leader or a subset of it) from the given record
@param [MARC4J4R::Record] r A MARC4J4R Record @return [String] the leader or substring of the leader
# File lib/marcspec/leaderspec.rb, line 29 def marc_values r if @range return r.leader[@range] else return r.leader end end