Class: Arrolio::Content::Formula
- Inherits:
-
Object
- Object
- Arrolio::Content::Formula
- Defined in:
- lib/arrolio/content/formula.rb
Overview
A formula — MathML root + rendered text fallback. Carries the math structure separately from how it's rendered (text fallback today, proper math typesetting in the future). The renderer can later use the MathML for accessible representation while the fallback provides visual rendering.
Instance Attribute Summary collapse
-
#mathml ⇒ Object
readonly
Returns the value of attribute mathml.
-
#style_id ⇒ Object
readonly
Returns the value of attribute style_id.
-
#text_fallback ⇒ Object
readonly
Returns the value of attribute text_fallback.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(mathml:, text_fallback:, style_id: :body) ⇒ Formula
constructor
A new instance of Formula.
Constructor Details
#initialize(mathml:, text_fallback:, style_id: :body) ⇒ Formula
Returns a new instance of Formula.
13 14 15 16 17 18 |
# File 'lib/arrolio/content/formula.rb', line 13 def initialize(mathml:, text_fallback:, style_id: :body) @mathml = mathml.to_s @text_fallback = text_fallback.to_s @style_id = style_id.to_sym freeze end |
Instance Attribute Details
#mathml ⇒ Object (readonly)
Returns the value of attribute mathml.
11 12 13 |
# File 'lib/arrolio/content/formula.rb', line 11 def mathml @mathml end |
#style_id ⇒ Object (readonly)
Returns the value of attribute style_id.
11 12 13 |
# File 'lib/arrolio/content/formula.rb', line 11 def style_id @style_id end |
#text_fallback ⇒ Object (readonly)
Returns the value of attribute text_fallback.
11 12 13 |
# File 'lib/arrolio/content/formula.rb', line 11 def text_fallback @text_fallback end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
20 21 22 23 24 25 |
# File 'lib/arrolio/content/formula.rb', line 20 def ==(other) other.is_a?(self.class) && mathml == other.mathml && text_fallback == other.text_fallback && style_id == other.style_id end |
#hash ⇒ Object
29 30 31 |
# File 'lib/arrolio/content/formula.rb', line 29 def hash [self.class, mathml, text_fallback, style_id].hash end |