Class: Arrolio::Content::Paragraph
- Inherits:
-
Object
- Object
- Arrolio::Content::Paragraph
- Defined in:
- lib/arrolio/content/paragraph.rb
Instance Attribute Summary collapse
-
#footnote_refs ⇒ Object
readonly
Returns the value of attribute footnote_refs.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#inline_runs ⇒ Object
readonly
Returns the value of attribute inline_runs.
-
#style_id ⇒ Object
readonly
Returns the value of attribute style_id.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #empty? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(inline_runs = [], style_id: :body, id: nil, footnote_refs: []) ⇒ Paragraph
constructor
A new instance of Paragraph.
- #text ⇒ Object
Constructor Details
#initialize(inline_runs = [], style_id: :body, id: nil, footnote_refs: []) ⇒ Paragraph
Returns a new instance of Paragraph.
8 9 10 11 12 13 14 |
# File 'lib/arrolio/content/paragraph.rb', line 8 def initialize(inline_runs = [], style_id: :body, id: nil, footnote_refs: []) @inline_runs = Array(inline_runs).freeze @style_id = style_id.to_sym @id = id @footnote_refs = Array(footnote_refs).freeze freeze end |
Instance Attribute Details
#footnote_refs ⇒ Object (readonly)
Returns the value of attribute footnote_refs.
6 7 8 |
# File 'lib/arrolio/content/paragraph.rb', line 6 def footnote_refs @footnote_refs end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/arrolio/content/paragraph.rb', line 6 def id @id end |
#inline_runs ⇒ Object (readonly)
Returns the value of attribute inline_runs.
6 7 8 |
# File 'lib/arrolio/content/paragraph.rb', line 6 def inline_runs @inline_runs end |
#style_id ⇒ Object (readonly)
Returns the value of attribute style_id.
6 7 8 |
# File 'lib/arrolio/content/paragraph.rb', line 6 def style_id @style_id end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
24 25 26 27 28 29 30 |
# File 'lib/arrolio/content/paragraph.rb', line 24 def ==(other) other.is_a?(self.class) && inline_runs == other.inline_runs && style_id == other.style_id && id == other.id && footnote_refs == other.footnote_refs end |
#empty? ⇒ Boolean
20 21 22 |
# File 'lib/arrolio/content/paragraph.rb', line 20 def empty? @inline_runs.empty? || text.strip.empty? end |
#hash ⇒ Object
33 34 35 |
# File 'lib/arrolio/content/paragraph.rb', line 33 def hash [self.class, inline_runs, style_id, id, footnote_refs].hash end |
#text ⇒ Object
16 17 18 |
# File 'lib/arrolio/content/paragraph.rb', line 16 def text @inline_runs.map(&:text).join end |