Class: Coradoc::AsciiDoc::Model::BibliographyEntry
- Inherits:
-
Base
- Object
- Lutaml::Model::Serializable
- Base
- Coradoc::AsciiDoc::Model::BibliographyEntry
- Defined in:
- lib/coradoc/asciidoc/model/bibliography_entry.rb
Overview
Individual bibliography entry for AsciiDoc documents.
Bibliography entries represent single references within a bibliography, with anchor names for citation linking.
Instance Attribute Summary collapse
-
#anchor_name ⇒ String?
readonly
The anchor name for citing this entry.
-
#document_id ⇒ String?
readonly
The document identifier.
-
#line_break ⇒ String
readonly
Line break character (default: “”).
-
#ref_text ⇒ String?
readonly
The reference text/citation.
Attributes inherited from Base
Class Method Summary collapse
-
.coerce_ref_text(raw) ⇒ String
Coerce a raw parser AST value into the canonical ref_text string.
Methods inherited from Base
#block_level?, #inline?, #serialize_content, #simplify_block_content, #to_adoc, #to_h, visit, #visit
Instance Attribute Details
#anchor_name ⇒ String? (readonly)
Returns The anchor name for citing this entry.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/coradoc/asciidoc/model/bibliography_entry.rb', line 30 class BibliographyEntry < Base attribute :anchor_name, :string attribute :document_id, :string attribute :ref_text, :string attribute :line_break, :string, default: -> { '' } # Coerce a raw parser AST value into the canonical ref_text string. # Accepts the shapes produced by Parser::Bibliography for `:ref_text`: # nil, Parslet::Slice, plain String, single Model::Base, or an Array # of any of these. Keeping this coercion on the model that owns # ref_text (rather than in a transformer rule) keeps the transformer # declarative and lets callers build entries from any source shape. # @param raw [Object, nil] # @return [String] def self.coerce_ref_text(raw) return '' if raw.nil? case raw when Array then raw.map { |e| coerce_ref_text(e) }.join when String then raw else raw.to_s end end end |
#document_id ⇒ String? (readonly)
Returns The document identifier.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/coradoc/asciidoc/model/bibliography_entry.rb', line 30 class BibliographyEntry < Base attribute :anchor_name, :string attribute :document_id, :string attribute :ref_text, :string attribute :line_break, :string, default: -> { '' } # Coerce a raw parser AST value into the canonical ref_text string. # Accepts the shapes produced by Parser::Bibliography for `:ref_text`: # nil, Parslet::Slice, plain String, single Model::Base, or an Array # of any of these. Keeping this coercion on the model that owns # ref_text (rather than in a transformer rule) keeps the transformer # declarative and lets callers build entries from any source shape. # @param raw [Object, nil] # @return [String] def self.coerce_ref_text(raw) return '' if raw.nil? case raw when Array then raw.map { |e| coerce_ref_text(e) }.join when String then raw else raw.to_s end end end |
#line_break ⇒ String (readonly)
Returns Line break character (default: “”).
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/coradoc/asciidoc/model/bibliography_entry.rb', line 30 class BibliographyEntry < Base attribute :anchor_name, :string attribute :document_id, :string attribute :ref_text, :string attribute :line_break, :string, default: -> { '' } # Coerce a raw parser AST value into the canonical ref_text string. # Accepts the shapes produced by Parser::Bibliography for `:ref_text`: # nil, Parslet::Slice, plain String, single Model::Base, or an Array # of any of these. Keeping this coercion on the model that owns # ref_text (rather than in a transformer rule) keeps the transformer # declarative and lets callers build entries from any source shape. # @param raw [Object, nil] # @return [String] def self.coerce_ref_text(raw) return '' if raw.nil? case raw when Array then raw.map { |e| coerce_ref_text(e) }.join when String then raw else raw.to_s end end end |
#ref_text ⇒ String? (readonly)
Returns The reference text/citation.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/coradoc/asciidoc/model/bibliography_entry.rb', line 30 class BibliographyEntry < Base attribute :anchor_name, :string attribute :document_id, :string attribute :ref_text, :string attribute :line_break, :string, default: -> { '' } # Coerce a raw parser AST value into the canonical ref_text string. # Accepts the shapes produced by Parser::Bibliography for `:ref_text`: # nil, Parslet::Slice, plain String, single Model::Base, or an Array # of any of these. Keeping this coercion on the model that owns # ref_text (rather than in a transformer rule) keeps the transformer # declarative and lets callers build entries from any source shape. # @param raw [Object, nil] # @return [String] def self.coerce_ref_text(raw) return '' if raw.nil? case raw when Array then raw.map { |e| coerce_ref_text(e) }.join when String then raw else raw.to_s end end end |
Class Method Details
.coerce_ref_text(raw) ⇒ String
Coerce a raw parser AST value into the canonical ref_text string. Accepts the shapes produced by Parser::Bibliography for ‘:ref_text`: nil, Parslet::Slice, plain String, single Model::Base, or an Array of any of these. Keeping this coercion on the model that owns ref_text (rather than in a transformer rule) keeps the transformer declarative and lets callers build entries from any source shape.
44 45 46 47 48 49 50 51 52 |
# File 'lib/coradoc/asciidoc/model/bibliography_entry.rb', line 44 def self.coerce_ref_text(raw) return '' if raw.nil? case raw when Array then raw.map { |e| coerce_ref_text(e) }.join when String then raw else raw.to_s end end |