lib/marc/datafield.rb in marc-0.2.1 vs lib/marc/datafield.rb in marc-0.2.2

- old
+ new

@@ -48,10 +48,16 @@ # field = MARC::DataField.new('245','0','0', # ['a', 'Consilience :'],['b','the unity of knowledge ', # ['c', 'by Edward O. Wilson.'] ) def initialize(tag, i1=' ', i2=' ', *subfields) - @tag = tag + # if the tag is less than 3 characters long and + # the string is all numeric then we pad with zeros + if tag.length < 3 and /^[0-9]*$/ =~ tag + @tag = "%03d" % tag + else + @tag = tag + end # can't allow nil to be passed in or else it'll # screw us up later when we try to encode @indicator1 = i1 == nil ? ' ' : i1 @indicator2 = i2 == nil ? ' ' : i2 @subfields = []