Class: NEU::MODS::Document

Inherits:
Object
  • Object
show all
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.

Constant Summary

Constants included from Projection

Projection::AUTHORITY_ATTRIBUTES, Projection::DATE_ELEMENTS, Projection::EMPTY_DATE, Projection::FIELDS, Projection::HEADING_OMITTED_CHILDREN, Projection::HEADING_SEPARATOR, Projection::HIERARCHICAL_GEOGRAPHIC_LEVELS, Projection::ISO8601_BASIC_DATE, Projection::ISO8601_ENCODING, Projection::MARC_COUNTRY_AUTHORITY, Projection::NAMED_HOST_DETAIL_TYPES, Projection::NAMED_RELATED_ITEM_TYPES, Projection::NON_SORT_BINDING, Projection::RECORD_INFO_PARTS, Projection::TITLE_SEPARATORS, Projection::TYPELESS_NAME_SUBJECT_TYPE, Projection::W3CDTF_DATE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Projection

#abbreviated_title, #abstract, #abstract_display_label, #abstract_href, #access_condition, #access_condition_display_label, #access_condition_href, #access_title_parts, #alternative_names, #alternative_title, cardinality_of, #classification, compose_title, #copyright_date, #copyright_date_display_label, #copyright_date_end, #copyright_date_end_precision, #copyright_date_event_type, #copyright_date_key_date, #copyright_date_parts, #copyright_date_precision, #copyright_date_qualifier, #copyright_date_text, #copyright_date_with_precision, #corporate_name_subjects, #date_captured, #date_captured_display_label, #date_captured_end, #date_captured_end_precision, #date_captured_event_type, #date_captured_key_date, #date_captured_parts, #date_captured_precision, #date_captured_qualifier, #date_captured_text, #date_created, #date_created_display_label, #date_created_end, #date_created_end_precision, #date_created_event_type, #date_created_key_date, #date_created_parts, #date_created_precision, #date_created_qualifier, #date_created_text, #date_created_with_precision, #date_issued, #date_issued_display_label, #date_issued_end, #date_issued_end_precision, #date_issued_event_type, #date_issued_key_date, #date_issued_parts, #date_issued_precision, #date_issued_qualifier, #date_issued_text, #date_issued_with_precision, #date_modified, #date_modified_display_label, #date_modified_end, #date_modified_end_precision, #date_modified_event_type, #date_modified_key_date, #date_modified_parts, #date_modified_precision, #date_modified_qualifier, #date_modified_text, #date_other, #date_other_display_label, #date_other_end, #date_other_end_precision, #date_other_event_type, #date_other_key_date, #date_other_parts, #date_other_precision, #date_other_qualifier, #date_other_text, #date_valid, #date_valid_display_label, #date_valid_end, #date_valid_end_precision, #date_valid_event_type, #date_valid_key_date, #date_valid_parts, #date_valid_precision, #date_valid_qualifier, #date_valid_text, #digital_origin, #editable_corporate_creators, #editable_personal_creators, #edition, #extent, fold_type, #format, #frequency, #genre_subjects, #genres, #geographic_code_subjects, #geographic_subjects, #hierarchical_geographic_subjects, #host_collections, #identifiers, #issuance, join_non_sort, #keywords, #languages, #location, #main_title, #main_title_display_label, #map_data, #name_entry, #names, #notes, #occupation_subjects, #origin_agents, #permanent_url, #permanent_url_display_label, #personal_name_subjects, #physical_description_notes, #place_of_publication, #place_term_value, #plain_title, #preserved_names, #publication_information, #record_info, #reformatting_quality, #related_items, #related_series, #resource_type, #restriction_on_access, #restriction_on_access_display_label, #restriction_on_access_href, #subject_headings, #table_of_contents, #target_audience, #temporal_subjects, #title_parts, #title_subjects, #to_h, #topical_subjects, #translated_title, #uniform_title, #use_and_reproduction, #use_and_reproduction_display_label, #use_and_reproduction_href

Methods included from Selectors

#abstract_nodes, #build_corporate_name, #build_node, #build_personal_name, #editable_creator_nodes, #keyword_subjects, #primary_title_info, #variant_title?

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

#docObject (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_xmlObject



33
34
35
# File 'lib/neu/mods/document.rb', line 33

def to_xml(...)
  doc.to_xml(...)
end