Class: Blacklight::Marc::Document
- Inherits:
-
Object
- Object
- Blacklight::Marc::Document
- Includes:
- Citation
- Defined in:
- vendor/plugins/blacklight/lib/blacklight/marc.rb
Instance Attribute Summary (collapse)
-
- (Object) marc
readonly
Returns the value of attribute marc.
Instance Method Summary (collapse)
-
- (Document) initialize(marc_data, marc_type)
constructor
A new instance of Document.
- - (Object) marc_xml
- - (Object) to_xml
Methods included from Citation
Constructor Details
- (Document) initialize(marc_data, marc_type)
A new instance of Document
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'vendor/plugins/blacklight/lib/blacklight/marc.rb', line 20 def initialize(marc_data, marc_type) case marc_type.to_s when 'marcxml' reader = MARC::XMLReader.new(StringIO.new(marc_data)).to_a @marc = reader[0] when 'marc21' reader = MARC::Record.new_from_marc(marc_data) @marc = reader else raise UnsupportedMarcFormatType.new("Only marcxml and marc21 are supported.") end end |
Instance Attribute Details
- (Object) marc (readonly)
Returns the value of attribute marc
16 17 18 |
# File 'vendor/plugins/blacklight/lib/blacklight/marc.rb', line 16 def marc @marc end |
Instance Method Details
- (Object) marc_xml
33 34 35 |
# File 'vendor/plugins/blacklight/lib/blacklight/marc.rb', line 33 def marc_xml @marc.to_xml.to_s end |
- (Object) to_xml
37 38 39 40 41 42 43 |
# File 'vendor/plugins/blacklight/lib/blacklight/marc.rb', line 37 def to_xml if @marc self.marc_xml else "<not-implemented/>" end end |