Class: Arrolio::Content::InlineRun
- Inherits:
-
Object
- Object
- Arrolio::Content::InlineRun
- Defined in:
- lib/arrolio/content/inline_run.rb
Overview
A single inline run of text within a paragraph. Carries the
text to render, the style_id for visual styling (bold,
italic, etc.), optional href for hyperlinks, and optional
baseline_shift / font_size_scale for subscript/superscript
positioning (used by MathML msub/msup rendering).
Constant Summary collapse
- BASELINE_NORMAL =
nil- BASELINE_SUB =
:sub- BASELINE_SUP =
:sup
Instance Attribute Summary collapse
-
#baseline_shift ⇒ Object
readonly
Returns the value of attribute baseline_shift.
-
#font_size_scale ⇒ Object
readonly
Returns the value of attribute font_size_scale.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#style_id ⇒ Object
readonly
Returns the value of attribute style_id.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(text, style_id: :inline, href: nil, baseline_shift: BASELINE_NORMAL, font_size_scale: 1.0) ⇒ InlineRun
constructor
A new instance of InlineRun.
- #subscript? ⇒ Boolean
- #superscript? ⇒ Boolean
Constructor Details
#initialize(text, style_id: :inline, href: nil, baseline_shift: BASELINE_NORMAL, font_size_scale: 1.0) ⇒ InlineRun
Returns a new instance of InlineRun.
17 18 19 20 21 22 23 24 25 |
# File 'lib/arrolio/content/inline_run.rb', line 17 def initialize(text, style_id: :inline, href: nil, baseline_shift: BASELINE_NORMAL, font_size_scale: 1.0) @text = text.to_s @style_id = style_id.to_sym @href = href @baseline_shift = baseline_shift @font_size_scale = font_size_scale.to_f freeze end |
Instance Attribute Details
#baseline_shift ⇒ Object (readonly)
Returns the value of attribute baseline_shift.
15 16 17 |
# File 'lib/arrolio/content/inline_run.rb', line 15 def baseline_shift @baseline_shift end |
#font_size_scale ⇒ Object (readonly)
Returns the value of attribute font_size_scale.
15 16 17 |
# File 'lib/arrolio/content/inline_run.rb', line 15 def font_size_scale @font_size_scale end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
15 16 17 |
# File 'lib/arrolio/content/inline_run.rb', line 15 def href @href end |
#style_id ⇒ Object (readonly)
Returns the value of attribute style_id.
15 16 17 |
# File 'lib/arrolio/content/inline_run.rb', line 15 def style_id @style_id end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
15 16 17 |
# File 'lib/arrolio/content/inline_run.rb', line 15 def text @text end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
27 28 29 30 31 32 33 34 |
# File 'lib/arrolio/content/inline_run.rb', line 27 def ==(other) other.is_a?(self.class) && text == other.text && style_id == other.style_id && href == other.href && baseline_shift == other.baseline_shift && font_size_scale == other.font_size_scale end |
#hash ⇒ Object
38 39 40 |
# File 'lib/arrolio/content/inline_run.rb', line 38 def hash [self.class, text, style_id, href, baseline_shift, font_size_scale].hash end |
#subscript? ⇒ Boolean
42 43 44 |
# File 'lib/arrolio/content/inline_run.rb', line 42 def subscript? @baseline_shift == BASELINE_SUB end |
#superscript? ⇒ Boolean
46 47 48 |
# File 'lib/arrolio/content/inline_run.rb', line 46 def superscript? @baseline_shift == BASELINE_SUP end |