Sha256: fde1afb3c99c15c7f796256ade13e26885e40e2d5642ea2c150a6a8cdb300ab4

Contents?: true

Size: 934 Bytes

Versions: 15

Compression:

Stored size: 934 Bytes

Contents

module MARC

  # MARC records contain control fields, each of which has a 
  # tag and value. Tags for control fields must be in the
  # 001-009 range.

  class ControlField

    # the tag value (007, 008, etc)
    attr_accessor :tag

    # the value of the control field
    attr_accessor :value

    # The constructor which must be passed a tag value and 
    # an optional value for the field.

    def initialize(tag,value='')
      @tag = tag
      @value = value
      if tag.to_i > 9 
        raise MARC::Exception.new(), "tag must be greater than 009"
      end
    end

    # Two control fields are equal if their tags and values are equal.

    def ==(other)
      if @tag != other.tag
        return false 
      elsif @value != other.value
        return false
      end
      return true
    end

    def to_s
      return "#{tag} #{value}" 
    end

    def =~(regex)
      return self.to_s =~ regex
    end

  end

end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
marc-0.1.0 lib/marc/controlfield.rb
marc-0.0.8 lib/marc/controlfield.rb
marc-0.0.9 lib/marc/controlfield.rb
marc-0.1.2 lib/marc/controlfield.rb
marc-0.1.5 lib/marc/controlfield.rb
marc-0.1.6 lib/marc/controlfield.rb
marc-0.1.7 lib/marc/controlfield.rb
marc-0.1.9 lib/marc/controlfield.rb
marc-0.2.1 lib/marc/controlfield.rb
marc-0.2.2 lib/marc/controlfield.rb
marc-0.1.3 lib/marc/controlfield.rb
marc-0.1.8 lib/marc/controlfield.rb
marc-0.1.4 lib/marc/controlfield.rb
marc-0.2.0 lib/marc/controlfield.rb
rwdgutenberg-0.13 lib/marc/controlfield.rb