Class: Marc4R::Fields::Subfield

Inherits:
Object
  • Object
show all
Includes:
Datable, Idable
Defined in:
lib/marc4r/fields/subfield.rb

Instance Attribute Summary collapse

Attributes included from Datable

#data

Attributes included from Idable

#id

Instance Method Summary collapse

Methods included from Datable

#=~

Constructor Details

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

Returns a new instance of Subfield.



5
6
7
8
# File 'lib/marc4r/fields/subfield.rb', line 5

def initialize(code=nil, data=nil)
  self.code = code if code
  self.data = data if data
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



4
5
6
# File 'lib/marc4r/fields/subfield.rb', line 4

def code
  @code
end

Instance Method Details

#to_sObject



9
10
11
# File 'lib/marc4r/fields/subfield.rb', line 9

def to_s
  "#{code}#{data}"
end