Class: Alumina::Atom
- Includes:
- HIN::Writer::Atom
- Defined in:
- lib/alumina/atom.rb
Overview
An atom as part of a Molecule.
Constant Summary collapse
- BOND_TYPES =
[ :single, :double, :triple, :aromatic ]
Instance Attribute Summary collapse
-
#bonds ⇒ Hash<Atom, Symbol>
the bond type.
-
#element ⇒ Element
The atomic type.
-
#id ⇒ Fixnum
The unique numerical identifier assigned to the atom.
- #ignored1 ⇒ Object
- #ignored2 ⇒ Object
-
#label ⇒ String?
The optional label given to the atom.
-
#partial_charge ⇒ Fixnum
The partial charge.
-
#x ⇒ Float
The atom’s x-coordinate in the molecule.
-
#y ⇒ Float
The atom’s y-coordinate in the molecule.
-
#z ⇒ Float
The atom’s z-coordinate in the molecule.
Class Method Summary collapse
-
.bind(atom1, atom2, type) ⇒ Object
Binds two atoms together.
Instance Method Summary collapse
-
#bond_count ⇒ Fixnum
The number of atoms bound to this atom.
-
#dup ⇒ Atom
Creates a duplicate of this atom with no bonds.
-
#initialize(id, element, x, y, z) ⇒ Atom
constructor
Initializes a new atom.
- #inspect ⇒ Object
Methods included from HIN::Writer::Atom
Constructor Details
Instance Attribute Details
#bonds ⇒ Hash<Atom, Symbol>
the bond type.
24 25 26 |
# File 'lib/alumina/atom.rb', line 24 def bonds @bonds end |
#element ⇒ Element
Returns The atomic type.
15 16 17 |
# File 'lib/alumina/atom.rb', line 15 def element @element end |
#id ⇒ Fixnum
Returns The unique numerical identifier assigned to the atom.
11 12 13 |
# File 'lib/alumina/atom.rb', line 11 def id @id end |
#ignored1 ⇒ Object
29 30 31 |
# File 'lib/alumina/atom.rb', line 29 def ignored1 @ignored1 end |
#ignored2 ⇒ Object
29 30 31 |
# File 'lib/alumina/atom.rb', line 29 def ignored2 @ignored2 end |
#label ⇒ String?
Returns The optional label given to the atom.
13 14 15 |
# File 'lib/alumina/atom.rb', line 13 def label @label end |
#partial_charge ⇒ Fixnum
Returns The partial charge.
26 27 28 |
# File 'lib/alumina/atom.rb', line 26 def partial_charge @partial_charge end |
#x ⇒ Float
Returns The atom’s x-coordinate in the molecule.
17 18 19 |
# File 'lib/alumina/atom.rb', line 17 def x @x end |
#y ⇒ Float
Returns The atom’s y-coordinate in the molecule.
19 20 21 |
# File 'lib/alumina/atom.rb', line 19 def y @y end |
#z ⇒ Float
Returns The atom’s z-coordinate in the molecule.
21 22 23 |
# File 'lib/alumina/atom.rb', line 21 def z @z end |
Class Method Details
.bind(atom1, atom2, type) ⇒ Object
Binds two atoms together.
58 59 60 61 62 63 |
# File 'lib/alumina/atom.rb', line 58 def self.bind(atom1, atom2, type) raise ArgumentError, "Invalid bond type #{type.inspect}" unless BOND_TYPES.include?(type) atom1.bonds[atom2] = type atom2.bonds[atom1] = type end |
Instance Method Details
#bond_count ⇒ Fixnum
Returns The number of atoms bound to this atom.
67 68 69 |
# File 'lib/alumina/atom.rb', line 67 def bond_count bonds.size end |
#dup ⇒ Atom
Creates a duplicate of this atom with no bonds.
75 76 77 78 79 80 81 82 |
# File 'lib/alumina/atom.rb', line 75 def dup atom = Atom.new(id, element, x, y, z) atom.label = label atom.partial_charge = partial_charge atom.ignored1 = ignored1 atom.ignored2 = ignored2 return atom end |
#inspect ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/alumina/atom.rb', line 85 def inspect if label then "#<Atom ##{id} #{label} (#{element.symbol})>" else "#<Atom ##{id} #{element.symbol}>" end end |