Class: AsciiChem::Model::EmbeddedMath
- Defined in:
- lib/asciichem/model/embedded_math.rb
Overview
A run of mathematics embedded in chemistry. Wraps a
Plurimath::Math::Formula so we never reinvent math typography.
Source spelling: backtick-delimited, e.g. `K_c = [P]/[R]`.
Instance Attribute Summary collapse
-
#formula ⇒ Object
Returns the value of attribute formula.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(formula:, source: nil) ⇒ EmbeddedMath
constructor
A new instance of EmbeddedMath.
- #to_s ⇒ Object
- #value_attributes ⇒ Object
Methods inherited from Node
#==, #accept, #children, #diagnostic_label, #hash, short_name, #to_cml, #to_html, #to_latex, #to_mathml, #to_svg, #to_text
Constructor Details
#initialize(formula:, source: nil) ⇒ EmbeddedMath
Returns a new instance of EmbeddedMath.
12 13 14 15 |
# File 'lib/asciichem/model/embedded_math.rb', line 12 def initialize(formula:, source: nil) @formula = formula @source = source end |
Instance Attribute Details
#formula ⇒ Object
Returns the value of attribute formula.
10 11 12 |
# File 'lib/asciichem/model/embedded_math.rb', line 10 def formula @formula end |
#source ⇒ Object
Returns the value of attribute source.
10 11 12 |
# File 'lib/asciichem/model/embedded_math.rb', line 10 def source @source end |
Instance Method Details
#to_s ⇒ Object
21 22 23 |
# File 'lib/asciichem/model/embedded_math.rb', line 21 def to_s "EmbeddedMath(#{source || formula.inspect})" end |
#value_attributes ⇒ Object
17 18 19 |
# File 'lib/asciichem/model/embedded_math.rb', line 17 def value_attributes { formula: formula, source: source } end |