Class: Chemicalml::Convention::Molecular::Constraints::BondOrderShouldNotBeNumeric

Inherits:
Constraint::NodeConstraint show all
Defined in:
lib/chemicalml/convention/molecular/constraints/bond_order_should_not_be_numeric.rb

Constant Summary collapse

VALID_ORDERS =
%w[S D T Q A other].freeze

Instance Method Summary collapse

Methods inherited from Constraint::NodeConstraint

#check

Instance Method Details

#check_node(node, path) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/chemicalml/convention/molecular/constraints/bond_order_should_not_be_numeric.rb', line 11

def check_node(node, path)

  order = node.order.to_s
  return [] if order.empty?

  return [] if VALID_ORDERS.include?(order) || node.dict_ref.to_s.size.positive?

  [violation(path: path.empty? ? 'bond' : path.join('/'),
             message: "bond order #{order.inspect} is not recommended " \
                      "(use S/D/T/Q/A or 'other' with dictRef)",
             severity: :warning)]
end