MARC records contain control fields, each of which has a tag and value. Tags for control fields must be in the 001-009 range or be specially added to the @@control_tags Set
the tag value (007, 008, etc)
the value of the control field
A tag is a control tag if tag.to_s is a member of the @@control_tags set.
# File lib/marc/controlfield.rb, line 19 def self.control_tag?(tag) return @@control_tags.include? tag.to_s end
The constructor which must be passed a tag value and an optional value for the field.
# File lib/marc/controlfield.rb, line 32 def initialize(tag,value='') @tag = tag @value = value if not MARC::ControlField.control_tag?(@tag) raise MARC::Exception.new(), "tag must be in 001-009 or in the MARC::ControlField.control_tags set" end end
Two control fields are equal if their tags and values are equal.
# File lib/marc/controlfield.rb, line 42 def ==(other) if @tag != other.tag return false elsif @value != other.value return false end return true end
# File lib/marc/controlfield.rb, line 65 def =~(regex) return self.to_s =~ regex end
Turn the control field into a hash for MARC-in-JSON
# File lib/marc/controlfield.rb, line 57 def to_hash return {@tag=>@value} end
turning it into a marc-hash element
# File lib/marc/controlfield.rb, line 52 def to_marchash return [@tag, @value] end
# File lib/marc/controlfield.rb, line 61 def to_s return "#{tag} #{value}" end