Class: AsciiChem::Linter::UnclosedRingCheck
- Defined in:
- lib/asciichem/linter/unclosed_ring_check.rb
Overview
Flags ring closure digits that have no matching partner. Catches
typos like C1-C-C (digit 1 opened but never closed). Uses
AsciiChem::RingBonds.unclosed_atoms as the source of truth.
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#run(formula) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/asciichem/linter/unclosed_ring_check.rb', line 11 def run(formula) diagnostics = [] walk(formula) do |node| next unless node.is_a?(AsciiChem::Model::Molecule) AsciiChem::RingBonds.unclosed_atoms(node).each do |atom| diagnostics << error( "Atom has unmatched ring closure digit(s) #{atom.ring_closures.inspect}", node: atom ) end end diagnostics end |