Class: Rubabel::Bond

Inherits:
Object show all
Includes:
Enumerable
Defined in:
lib/rubabel/bond.rb

Overview

delegates to obbond object if the method is missing

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Enumerable

#index_by, #uniq_by

Constructor Details

#initialize(obbond) ⇒ Bond

Returns a new instance of Bond.



38
39
40
# File 'lib/rubabel/bond.rb', line 38

def initialize(obbond)
  @ob = obbond
end

Instance Attribute Details

#obObject

Returns the value of attribute ob.



36
37
38
# File 'lib/rubabel/bond.rb', line 36

def ob
  @ob
end

Instance Method Details

#atomsObject

returns an array of Rubabel::Atoms



67
68
69
# File 'lib/rubabel/bond.rb', line 67

def atoms
  [@ob.get_begin_atom.upcast, @ob.get_end_atom.upcast]
end

#bond_orderObject



57
58
59
# File 'lib/rubabel/bond.rb', line 57

def bond_order
  @ob.get_bond_order
end

#bond_order=(val = 1) ⇒ Object

1 = single, 2 = double, 5 = aromatic



62
63
64
# File 'lib/rubabel/bond.rb', line 62

def bond_order=(val=1)
  @ob.set_bond_order(val)
end

#each_atom(&block) ⇒ Object Also known as: each



48
49
50
51
52
53
# File 'lib/rubabel/bond.rb', line 48

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

#include?(atom) ⇒ Boolean

considered included if the atom ids match

Returns:

  • (Boolean)


43
44
45
46
# File 'lib/rubabel/bond.rb', line 43

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

#inspectObject



71
72
73
# File 'lib/rubabel/bond.rb', line 71

def inspect
  "[#{atoms.map(&:inspect).join('-')}]"
end