Sha256: 74fdc16912b8b97788ba4812ee3c29f8d2dd0795eac737070c0ab46001c7a48d

Contents?: true

Size: 795 Bytes

Versions: 1

Compression:

Stored size: 795 Bytes

Contents

# frozen_string_literal: true

module ChemScanner
  module Interpreter
    # MoleculeGroup - molecules represented as text
    class MoleculeGroup
      attr_accessor :title
      attr_reader :polygon, :molecules, :molecule_ids

      def initialize(title = nil)
        @title = title
        @molecules = []
        @molecule_ids = []
      end

      def add_fragment(fragment)
        mol = Molecule.new(fragment)
        mol.process
        mol.abbreviation = title.value
        molecules.push(mol)
        @molecule_ids.push(fragment.id)
      end

      def inspect
        (
          "#<MoleculeGroup: id=#{@title.id}, " +
            "text: #{@title}, " +
            "molecule_ids: #{@molecule_ids}, " +
            "molecules: #{@molecules} >"
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chem_scanner-0.1.3 lib/chem_scanner/interpreter/element/molecule_group.rb