Class: AsciiChem::Model::ReactionCascade

Inherits:
Node
  • Object
show all
Defined in:
lib/asciichem/model/reaction_cascade.rb

Overview

A multi-step reaction cascade: an ordered list of Reaction objects where each step's products are the next step's reactants. Source spelling is a chain of arrows:

A -> B -> C -> D

Single-step reactions stay as Reaction; only multi-step sequences promote to ReactionCascade.

Instance Attribute Summary collapse

Instance Method Summary collapse

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(steps:) ⇒ ReactionCascade

Returns a new instance of ReactionCascade.



16
17
18
# File 'lib/asciichem/model/reaction_cascade.rb', line 16

def initialize(steps:)
  @steps = steps
end

Instance Attribute Details

#stepsObject

Returns the value of attribute steps.



14
15
16
# File 'lib/asciichem/model/reaction_cascade.rb', line 14

def steps
  @steps
end

Instance Method Details

#childrenObject



24
25
26
# File 'lib/asciichem/model/reaction_cascade.rb', line 24

def children
  steps
end

#to_sObject



28
29
30
# File 'lib/asciichem/model/reaction_cascade.rb', line 28

def to_s
  "ReactionCascade(#{steps.map(&:to_s).join(' >> ')})"
end

#value_attributesObject



20
21
22
# File 'lib/asciichem/model/reaction_cascade.rb', line 20

def value_attributes
  { steps: steps }
end