Class: NEU::MODS::Document
- Inherits:
-
Object
- Object
- NEU::MODS::Document
- Includes:
- Projection, Selectors
- Defined in:
- lib/neu/mods/document.rb
Overview
The gem’s main entry point: a thin facade over a parsed MODS document.
doc = NEU::MODS::Document.parse(xml)
doc.plain_title # => composed display title
doc.to_h # => full read projection
doc.primary_title_info # => a live Nokogiri node (for editing)
Selectors return live nodes (shared by read and write); projection methods return plain data. Parsing uses ‘&:noblanks` to match Atlas’s read and to avoid spurious whitespace-only text nodes.
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(nokogiri_doc) ⇒ Document
constructor
Wrap an already-parsed Nokogiri document (used by writers that own the doc they’re mutating, so selectors and serialization share one instance).
- #to_xml ⇒ Object
Methods included from Projection
#abstract, #access_condition, compose_title, #date_created, #digital_origin, #extent, #format, #genres, #identifiers, #keywords, #languages, #names, #permanent_url, #plain_title, #related_series, #resource_type, #title_parts, #to_h, #topical_subjects
Methods included from Selectors
#abstract_nodes, #build_node, #keyword_subjects, #primary_title_info
Constructor Details
#initialize(nokogiri_doc) ⇒ Document
Wrap an already-parsed Nokogiri document (used by writers that own the doc they’re mutating, so selectors and serialization share one instance).
29 30 31 |
# File 'lib/neu/mods/document.rb', line 29 def initialize(nokogiri_doc) @doc = nokogiri_doc end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
21 22 23 |
# File 'lib/neu/mods/document.rb', line 21 def doc @doc end |
Class Method Details
.parse(xml) ⇒ Object
23 24 25 |
# File 'lib/neu/mods/document.rb', line 23 def self.parse(xml) new(Nokogiri::XML(xml.to_s, &:noblanks)) end |
Instance Method Details
#to_xml ⇒ Object
33 34 35 |
# File 'lib/neu/mods/document.rb', line 33 def to_xml(...) doc.to_xml(...) end |