Class: MARC4J4R::SubField

Inherits:
Object
  • Object
show all
Defined in:
lib/marc4j4r/datafield.rb

Instance Method Summary collapse

Constructor Details

#initialize(code = nil, data = nil) ⇒ SubField

Returns a new instance of SubField.



155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/marc4j4r/datafield.rb', line 155

def initialize code=nil, data=nil
  if code
    code = code[0].ord
    if data
      self.oldinit(code, data)
    else
      self.oldinit(code)
    end
  else
    self.oldinit
  end
end

Instance Method Details

#==(other) ⇒ Object



168
169
170
# File 'lib/marc4j4r/datafield.rb', line 168

def == other
  return ((self.code == other.code) and (self.data == other.data))
end

#codeObject



180
181
182
# File 'lib/marc4j4r/datafield.rb', line 180

def code
  return self.getCode.chr
end

#code=(str) ⇒ Object



184
185
186
# File 'lib/marc4j4r/datafield.rb', line 184

def code= str
  self.setCode str[0].ord
end

#oldinitObject



154
# File 'lib/marc4j4r/datafield.rb', line 154

alias_method :oldinit, :initialize

#to_sObject



188
189
190
# File 'lib/marc4j4r/datafield.rb', line 188

def to_s
  return '$' + self.code + " " + self.data
end

#valueObject



172
173
174
# File 'lib/marc4j4r/datafield.rb', line 172

def value
  return self.data
end

#value=(str) ⇒ Object



176
177
178
# File 'lib/marc4j4r/datafield.rb', line 176

def value= str
  self.data = str
end