Class: AsciiChem::Model::Formula
- Defined in:
- lib/asciichem/model/formula.rb
Overview
Top-level container: the root of every AsciiChem parse.
Instance Attribute Summary collapse
-
#nodes ⇒ Object
Returns the value of attribute nodes.
Instance Method Summary collapse
- #<<(node) ⇒ Object
- #children ⇒ Object
-
#initialize(nodes: []) ⇒ Formula
constructor
A new instance of Formula.
- #to_s ⇒ Object
- #value_attributes ⇒ Object
Methods inherited from Node
#==, #accept, #diagnostic_label, #hash, short_name, #to_cml, #to_html, #to_latex, #to_mathml, #to_svg, #to_text
Constructor Details
#initialize(nodes: []) ⇒ Formula
Returns a new instance of Formula.
9 10 11 |
# File 'lib/asciichem/model/formula.rb', line 9 def initialize(nodes: []) @nodes = nodes end |
Instance Attribute Details
#nodes ⇒ Object
Returns the value of attribute nodes.
7 8 9 |
# File 'lib/asciichem/model/formula.rb', line 7 def nodes @nodes end |
Instance Method Details
#<<(node) ⇒ Object
13 14 15 16 |
# File 'lib/asciichem/model/formula.rb', line 13 def <<(node) nodes << node self end |
#children ⇒ Object
22 23 24 |
# File 'lib/asciichem/model/formula.rb', line 22 def children nodes end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/asciichem/model/formula.rb', line 26 def to_s "Formula[#{nodes.map(&:to_s).join(', ')}]" end |
#value_attributes ⇒ Object
18 19 20 |
# File 'lib/asciichem/model/formula.rb', line 18 def value_attributes { nodes: nodes } end |