Module: Metanorma::Mirror::Metadata
- Defined in:
- lib/metanorma/mirror/metadata.rb
Overview
Extracts metadata (title, etc.) from a parsed Metanorma document's bibdata. This is a standalone service that the pipeline and other consumers can use without depending on the Handlers layer.
Class Method Summary collapse
-
.title_from_bibdata(bibdata) ⇒ Object
Returns the first title string from a bibdata object, or nil.
Class Method Details
.title_from_bibdata(bibdata) ⇒ Object
Returns the first title string from a bibdata object, or nil.
The bibdata must respond to title and return a String, an Array
of Strings, or an Array of Lutaml::Model::Serializables with
content.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/metanorma/mirror/metadata.rb', line 13 def self.title_from_bibdata(bibdata) return nil unless bibdata title = bibdata.title return nil unless title case title when String then title when Array first = title.first return nil unless first if first.is_a?(String) first elsif first.is_a?(Lutaml::Model::Serializable) Array(first.content).join else first.to_s end else title.to_s end end |