Class: MARC::ControlField
Overview
MARC records contain control fields, each of which has a tag and value. Tags for control fields must be in the 001-009 range.
Instance Attribute Summary collapse
-
#tag ⇒ Object
the tag value (007, 008, etc).
-
#value ⇒ Object
the value of the control field.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Two control fields are equal if their tags and values are equal.
- #=~(regex) ⇒ Object
-
#initialize(tag, value = '') ⇒ ControlField
constructor
The constructor which must be passed a tag value and an optional value for the field.
- #to_s ⇒ Object
Constructor Details
#initialize(tag, value = '') ⇒ ControlField
The constructor which must be passed a tag value and an optional value for the field.
18 19 20 21 22 23 24 |
# File 'lib/marc/controlfield.rb', line 18 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 |
Instance Attribute Details
#tag ⇒ Object
the tag value (007, 008, etc)
10 11 12 |
# File 'lib/marc/controlfield.rb', line 10 def tag @tag end |
#value ⇒ Object
the value of the control field
13 14 15 |
# File 'lib/marc/controlfield.rb', line 13 def value @value end |
Instance Method Details
#==(other) ⇒ Object
Two control fields are equal if their tags and values are equal.
28 29 30 31 32 33 34 35 |
# File 'lib/marc/controlfield.rb', line 28 def ==(other) if @tag != other.tag return false elsif @value != other.value return false end return true end |
#=~(regex) ⇒ Object
41 42 43 |
# File 'lib/marc/controlfield.rb', line 41 def =~(regex) return self.to_s =~ regex end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/marc/controlfield.rb', line 37 def to_s return "#{tag} #{value}" end |