Class: ChemScanner::Interpreter::MoleculeGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/chem_scanner/interpreter/element/molecule_group.rb

Overview

MoleculeGroup - molecules represented as text

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title = nil) ⇒ MoleculeGroup

Returns a new instance of MoleculeGroup.



10
11
12
13
14
# File 'lib/chem_scanner/interpreter/element/molecule_group.rb', line 10

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

Instance Attribute Details

#molecule_idsObject (readonly)

Returns the value of attribute molecule_ids.



8
9
10
# File 'lib/chem_scanner/interpreter/element/molecule_group.rb', line 8

def molecule_ids
  @molecule_ids
end

#moleculesObject (readonly)

Returns the value of attribute molecules.



8
9
10
# File 'lib/chem_scanner/interpreter/element/molecule_group.rb', line 8

def molecules
  @molecules
end

#polygonObject (readonly)

Returns the value of attribute polygon.



8
9
10
# File 'lib/chem_scanner/interpreter/element/molecule_group.rb', line 8

def polygon
  @polygon
end

#titleObject

Returns the value of attribute title.



7
8
9
# File 'lib/chem_scanner/interpreter/element/molecule_group.rb', line 7

def title
  @title
end

Instance Method Details

#add_fragment(fragment) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/chem_scanner/interpreter/element/molecule_group.rb', line 16

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

#inspectObject



24
25
26
27
28
29
30
31
# File 'lib/chem_scanner/interpreter/element/molecule_group.rb', line 24

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