Class: Relaton::Bib::Title
- Inherits:
-
LocalizedMarkedUpString
- Object
- Lutaml::Model::Serializable
- LocalizedStringAttrs
- LocalizedMarkedUpString
- Relaton::Bib::Title
- Defined in:
- lib/relaton/bib/model/title.rb
Class Method Summary collapse
Class Method Details
.from_string(title, lang = nil, script = nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/relaton/bib/model/title.rb', line 18 def from_string(title, lang = nil, script = nil) types = %w[title-intro title-main title-part] ttls = split_title(title) tts = ttls.map.with_index do |p, i| next unless p new type: types[i], content: p, language: lang, script: script end.compact tts << new(type: "main", content: ttls.compact.join(" - "), language: lang, script: script) tts end |