class Rubabel::Bond

delegates to obbond object if the method is missing

Attributes

ob[RW]

Public Class Methods

new(obbond) click to toggle source
# File lib/rubabel/bond.rb, line 40
def initialize(obbond)
  @ob = obbond
end

Public Instance Methods

+(val) click to toggle source

Increases the bond order and returns a new Rubabel::Bond object–but it will still be pointing to the same underlying @ob object.

# File lib/rubabel/bond.rb, line 106
def +(val)
  inc!(val)
  @ob.upcast
end
-(val) click to toggle source

Decreases the bond order and returns a new Rubabel::Bond object–but it will still be pointing to the same underlying @ob object. Won’t decrease below zero.

# File lib/rubabel/bond.rb, line 127
def -(val)
  self.+(-val)
end
atoms() click to toggle source

returns an array of Rubabel::Atoms

# File lib/rubabel/bond.rb, line 90
def atoms
  [@ob.get_begin_atom.upcast, @ob.get_end_atom.upcast]
end
bond_order() click to toggle source
# File lib/rubabel/bond.rb, line 59
def bond_order
  @ob.get_bond_order
end
Also aliased as: order
bond_order=(val=1) click to toggle source

1 = single, 2 = double, 5 = aromatic

# File lib/rubabel/bond.rb, line 65
def bond_order=(val=1)
  @ob.set_bond_order(val)
end
Also aliased as: order=
dec!(val=1) click to toggle source

decrease the bond order by val

# File lib/rubabel/bond.rb, line 120
def dec!(val=1)
  inc!(-val)
end
each(&block)
Alias for: each_atom
each_atom(&block) click to toggle source
# File lib/rubabel/bond.rb, line 50
def each_atom(&block)
  block or return enum_for(__method__)
  block.call @ob.get_begin_atom.upcast
  block.call @ob.get_end_atom.upcast
  self
end
Also aliased as: each
inc!(val=1) click to toggle source

increase the bond order by val

# File lib/rubabel/bond.rb, line 112
def inc!(val=1)
  newval = @ob.get_bond_order + val
  newval = 0 if newval < 0
  @ob.set_bond_order(newval)
  self
end
include?(atom) click to toggle source

considered included if the atom ids match

# File lib/rubabel/bond.rb, line 45
def include?(atom)
  # atoms.any? {|atm| atom.id == atm.id }
  (@ob.get_begin_atom.get_id == atom.id) || (@ob.get_end_atom.get_id == atom.id)
end
inspect() click to toggle source
# File lib/rubabel/bond.rb, line 94
def inspect
  bond_symbol = case bond_order
  when 2 then '='
  when 3 then '≡'
  else 
    '-'
  end
  "#{atoms.map(&:inspect).join(bond_symbol)}"
end
order()
Alias for: bond_order
order=(val=1)
Alias for: bond_order=
set_atoms!(beg_atom, end_atom) click to toggle source

returns self

# File lib/rubabel/bond.rb, line 71
def set_atoms!(beg_atom, end_atom)
  @ob.set_begin(beg_atom.ob)
  @ob.set_end(end_atom.ob)
  self
end
set_begin!(atom) click to toggle source

Sets the beginning atom of the bond to atom. returns self

# File lib/rubabel/bond.rb, line 78
def set_begin!(atom)
  @ob.set_begin(atom.ob)
  self
end
set_end!(atom) click to toggle source

Sets the end atom of the bond to the given atom. returns self

# File lib/rubabel/bond.rb, line 84
def set_end!(atom)
  @ob.set_end(atom.ob)
  self
end