Class: AsciiChem::Linter::ValenceCheck
- Defined in:
- lib/asciichem/linter/valence_check.rb
Overview
Verifies that each atom's total bond order plus |charge| does not
exceed the element's typical valence. Catches typos like CH_5
(carbon with five bonds).
The valence table lists common valences per element. Unknown elements produce an info diagnostic, not an error.
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#run(formula) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/asciichem/linter/valence_check.rb', line 14 def run(formula) diagnostics = [] # Walk molecules so we know which atom is the bonding context. walk(formula) do |node| next unless node.is_a?(AsciiChem::Model::Molecule) check_molecule(node, diagnostics) end diagnostics end |