Class: AsciiChem::Model::Bond
Overview
A bond between two adjacent nodes in a structural chain.
Constant Summary collapse
- KINDS =
{ single: { ascii: "-", mathml_entity: "-" }, double: { ascii: "=", mathml_entity: "=" }, triple: { ascii: "#", mathml_entity: "≡" }, quadruple: { ascii: "##", mathml_entity: "≣" }, wedge: { ascii: ">-", mathml_entity: "↑" }, hash: { ascii: "-<", mathml_entity: "↓" }, dative: { ascii: "~>", mathml_entity: "→" }, wavy: { ascii: "~~", mathml_entity: "∼" } }.freeze
Instance Attribute Summary collapse
-
#kind ⇒ Object
Returns the value of attribute kind.
Instance Method Summary collapse
- #ascii ⇒ Object
- #entity ⇒ Object
-
#initialize(kind: :single) ⇒ Bond
constructor
A new instance of Bond.
- #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(kind: :single) ⇒ Bond
Returns a new instance of Bond.
20 21 22 |
# File 'lib/asciichem/model/bond.rb', line 20 def initialize(kind: :single) @kind = kind end |
Instance Attribute Details
#kind ⇒ Object
Returns the value of attribute kind.
7 8 9 |
# File 'lib/asciichem/model/bond.rb', line 7 def kind @kind end |
Instance Method Details
#ascii ⇒ Object
28 29 30 |
# File 'lib/asciichem/model/bond.rb', line 28 def ascii KINDS.fetch(kind).fetch(:ascii) end |
#entity ⇒ Object
32 33 34 |
# File 'lib/asciichem/model/bond.rb', line 32 def entity KINDS.fetch(kind).fetch(:mathml_entity) end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/asciichem/model/bond.rb', line 36 def to_s "Bond(#{kind})" end |
#value_attributes ⇒ Object
24 25 26 |
# File 'lib/asciichem/model/bond.rb', line 24 def value_attributes { kind: kind } end |