Sha256: 921b9ca42339d3f1781c69b1d544ff190beb3a71b1f355ad0645eaa9e7e12bff
Contents?: true
Size: 910 Bytes
Versions: 1
Compression:
Stored size: 910 Bytes
Contents
require 'rubabel/atom' class OpenBabel::OBBond def upcast Rubabel::Bond.new(self) end end module Rubabel # delegates to obbond object if the method is missing class Bond include Enumerable attr_accessor :ob def initialize(obbond) @ob = obbond end # considered included if the atom ids match 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 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 alias_method :each, :each_atom # returns an array of Rubabel::Atoms def atoms [@ob.get_begin_atom.upcast, @ob.get_end_atom.upcast] end def inspect "[#{atoms.map(&:inspect).join('-')}]" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubabel-0.1.0 | lib/rubabel/bond.rb |