Class: AsciiChem::Linter::IsotopeSanityCheck

Inherits:
Base
  • Object
show all
Defined in:
lib/asciichem/linter/isotope_sanity_check.rb

Overview

Sanity-checks isotope mass numbers against the element's atomic number. The isotope's mass must be ≥ the atomic number (a nucleus can't have fewer protons than its mass number suggests).

Atomic-number table is limited to common elements; unknown elements produce an info diagnostic, not an error.

Instance Method Summary collapse

Methods inherited from Base

register

Instance Method Details

#run(formula) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/asciichem/linter/isotope_sanity_check.rb', line 14

def run(formula)
  diagnostics = []
  walk(formula) do |node|
    next unless node.is_a?(AsciiChem::Model::Atom)
    next unless node.isotope

    check_atom(node, diagnostics)
  end
  diagnostics
end