Class: Arrolio::Content::BibliographyItem
- Inherits:
-
Object
- Object
- Arrolio::Content::BibliographyItem
- Defined in:
- lib/arrolio/content/bibliography_item.rb
Overview
A single bibliography entry: citation tag (e.g. "[Smith2020]") and a formatted reference Paragraph. Renders with a hanging-indent so wrapped lines align under the text, not the citation tag.
Instance Attribute Summary collapse
-
#formattedref ⇒ Object
readonly
Returns the value of attribute formattedref.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#style_id ⇒ Object
readonly
Returns the value of attribute style_id.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #empty? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(formattedref:, tag: nil, id: nil, style_id: :bibitem) ⇒ BibliographyItem
constructor
A new instance of BibliographyItem.
- #text ⇒ Object
Constructor Details
#initialize(formattedref:, tag: nil, id: nil, style_id: :bibitem) ⇒ BibliographyItem
Returns a new instance of BibliographyItem.
12 13 14 15 16 17 18 |
# File 'lib/arrolio/content/bibliography_item.rb', line 12 def initialize(formattedref:, tag: nil, id: nil, style_id: :bibitem) @tag = tag @formattedref = formattedref @id = id&.to_s @style_id = style_id.to_sym freeze end |
Instance Attribute Details
#formattedref ⇒ Object (readonly)
Returns the value of attribute formattedref.
10 11 12 |
# File 'lib/arrolio/content/bibliography_item.rb', line 10 def formattedref @formattedref end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/arrolio/content/bibliography_item.rb', line 10 def id @id end |
#style_id ⇒ Object (readonly)
Returns the value of attribute style_id.
10 11 12 |
# File 'lib/arrolio/content/bibliography_item.rb', line 10 def style_id @style_id end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
10 11 12 |
# File 'lib/arrolio/content/bibliography_item.rb', line 10 def tag @tag end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
28 29 30 31 32 33 34 |
# File 'lib/arrolio/content/bibliography_item.rb', line 28 def ==(other) other.is_a?(self.class) && tag == other.tag && formattedref == other.formattedref && id == other.id && style_id == other.style_id end |
#empty? ⇒ Boolean
24 25 26 |
# File 'lib/arrolio/content/bibliography_item.rb', line 24 def empty? @tag.nil? && (@formattedref.nil? || (@formattedref.is_a?(Paragraph) && @formattedref.empty?)) end |
#hash ⇒ Object
37 38 39 |
# File 'lib/arrolio/content/bibliography_item.rb', line 37 def hash [self.class, tag, formattedref, id, style_id].hash end |
#text ⇒ Object
20 21 22 |
# File 'lib/arrolio/content/bibliography_item.rb', line 20 def text @formattedref.is_a?(Paragraph) ? @formattedref.text : @formattedref.to_s end |