Class: Marcxella::Record
- Inherits:
-
Object
- Object
- Marcxella::Record
- Defined in:
- lib/marcxella/record.rb
Overview
Wrapper for a record element
Instance Attribute Summary collapse
-
#fields ⇒ Array<ControlField, DataField>
readonly
The control and data fields of the record.
-
#leader ⇒ String
readonly
the record leader.
-
#node ⇒ Nokogiri::XML::Document
readonly
the wrapped record element node.
Instance Method Summary collapse
-
#addedEntries ⇒ Array<DataField>
The added entry fields (70X-75X).
-
#codes ⇒ Array<DataField>
The numbers and code fields (01X-09X).
-
#controlFields ⇒ Array<ControlField>
The control fields (00X).
-
#description ⇒ Array<DataField>
The physical description fields (3XX).
-
#edition ⇒ Array<DataField>
The edition- and imprint-related fields (25X-28X).
-
#field(tag) ⇒ Array<DataField>, Array<ControlField>
Get fields by a tag.
-
#holdings ⇒ Array<DataField>
The holdings, alternate graphics, etc fields (841-88X).
-
#include?(tag, code = nil) ⇒ boolean
Does the record include a field with a specific tag?.
-
#initialize(node) ⇒ Record
constructor
A new instance of Record.
-
#isbns ⇒ Array<String>
The International Standard Book Number (020$a).
-
#issns ⇒ Array<String>
The International Standard Serial Number (022$a).
-
#lccn ⇒ String
The Library of Congress Control Number (010$a).
-
#linking ⇒ Array<DataField>
The linking entry fields (76X-78X).
-
#mainEntry ⇒ DataField
The record’s main entry field.
-
#notes ⇒ Array<DataField>
The note statement fields (5XX).
-
#series ⇒ Array<DataField>
The series statement fields (4XX).
-
#seriesAdded ⇒ Array<DataField>
The series added entry fields (80X-83X).
-
#subfield(tag, code) ⇒ Array<SubField>
get a subfield from matching fields, for instance all 651$a subfields.
-
#subjects ⇒ Array<DataField>
The subject access fields (6XX).
-
#titles ⇒ Array<DataField>
The title- and title-related fields (20X-24X).
-
#titleStatement ⇒ DataField
The record’s title statement.
Constructor Details
#initialize(node) ⇒ Record
Returns a new instance of Record.
9 10 11 12 13 |
# File 'lib/marcxella/record.rb', line 9 def initialize(node) @node = node @leader = node.css('leader').text @fields = node.css('controlfield, datafield').map{|f| objectify f} end |
Instance Attribute Details
#fields ⇒ Array<ControlField, DataField> (readonly)
The control and data fields of the record
25 26 27 |
# File 'lib/marcxella/record.rb', line 25 def fields @fields end |
#leader ⇒ String (readonly)
the record leader
7 8 9 |
# File 'lib/marcxella/record.rb', line 7 def leader @leader end |
#node ⇒ Nokogiri::XML::Document (readonly)
the wrapped record element node
7 8 9 |
# File 'lib/marcxella/record.rb', line 7 def node @node end |
Instance Method Details
#addedEntries ⇒ Array<DataField>
The added entry fields (70X-75X)
135 136 137 |
# File 'lib/marcxella/record.rb', line 135 def addedEntries tag_range("700", "75X") end |
#codes ⇒ Array<DataField>
The numbers and code fields (01X-09X)
72 73 74 |
# File 'lib/marcxella/record.rb', line 72 def codes tag_range("010", "09X") end |
#controlFields ⇒ Array<ControlField>
The control fields (00X)
63 64 65 |
# File 'lib/marcxella/record.rb', line 63 def controlFields tag_range("001", "009") end |
#description ⇒ Array<DataField>
The physical description fields (3XX)
99 100 101 |
# File 'lib/marcxella/record.rb', line 99 def description tag_range("300", "399") end |
#edition ⇒ Array<DataField>
The edition- and imprint-related fields (25X-28X)
90 91 92 |
# File 'lib/marcxella/record.rb', line 90 def edition tag_range("250", "28X") end |
#field(tag) ⇒ Array<DataField>, Array<ControlField>
Get fields by a tag
19 20 21 |
# File 'lib/marcxella/record.rb', line 19 def field(tag) return @fields.select{|f| f.tag == tag} end |
#holdings ⇒ Array<DataField>
The holdings, alternate graphics, etc fields (841-88X)
162 163 164 |
# File 'lib/marcxella/record.rb', line 162 def holdings tag_range("841", "88X") end |
#include?(tag, code = nil) ⇒ boolean
Does the record include a field with a specific tag?
33 34 35 |
# File 'lib/marcxella/record.rb', line 33 def include?(tag, code = nil) not field(tag, code).empty? end |
#isbns ⇒ Array<String>
The International Standard Book Number (020$a)
179 180 181 |
# File 'lib/marcxella/record.rb', line 179 def isbns subfield("020", "a").map{|s| s.value} end |
#issns ⇒ Array<String>
The International Standard Serial Number (022$a)
186 187 188 |
# File 'lib/marcxella/record.rb', line 186 def issns subfield("022", "a").map{|s| s.value} end |
#lccn ⇒ String
The Library of Congress Control Number (010$a). Only returns the $a
subfields, nothing from the $b or $z
170 171 172 173 174 |
# File 'lib/marcxella/record.rb', line 170 def lccn s = subfield("010", "a") return nil if s.empty? s.first.value end |
#linking ⇒ Array<DataField>
The linking entry fields (76X-78X)
144 145 146 |
# File 'lib/marcxella/record.rb', line 144 def linking tag_range("760", "78X") end |
#mainEntry ⇒ DataField
The record’s main entry field. Every record should have one (and only one) of the 1XX fields (100, 110, 111, 130).
44 45 46 |
# File 'lib/marcxella/record.rb', line 44 def mainEntry tag_range("100", "1XX").first end |
#notes ⇒ Array<DataField>
The note statement fields (5XX)
117 118 119 |
# File 'lib/marcxella/record.rb', line 117 def notes tag_range("500", "59X") end |
#series ⇒ Array<DataField>
The series statement fields (4XX)
108 109 110 |
# File 'lib/marcxella/record.rb', line 108 def series tag_range("400", "499") end |
#seriesAdded ⇒ Array<DataField>
The series added entry fields (80X-83X)
153 154 155 |
# File 'lib/marcxella/record.rb', line 153 def seriesAdded tag_range("800", "83X") end |
#subfield(tag, code) ⇒ Array<SubField>
get a subfield from matching fields, for instance all 651$a subfields
209 210 211 |
# File 'lib/marcxella/record.rb', line 209 def subfield(tag, code) field(tag).map{|f| f.subfields.select{|s| s.code == code } }.flatten end |
#subjects ⇒ Array<DataField>
The subject access fields (6XX)
126 127 128 |
# File 'lib/marcxella/record.rb', line 126 def subjects tag_range("600", "69X") end |
#titles ⇒ Array<DataField>
The title- and title-related fields (20X-24X)
81 82 83 |
# File 'lib/marcxella/record.rb', line 81 def titles tag_range("200", "24X2") end |
#titleStatement ⇒ DataField
The record’s title statement. That is, its 245 field
54 55 56 |
# File 'lib/marcxella/record.rb', line 54 def titleStatement field("245").first end |