class OpenBabel::OBConversion
Constants
- OUT_OPTS_SHORT
Public Instance Methods
add_opts!(type=:gen, *opts)
click to toggle source
adds the opts to the type, where type is :gen, :out, or :in. takes opts as either a hash or a list:
# hash obconv.add_opts!(:out, d: true, u: true, p: 10 ) # list obconv.add_opts!(:out, :d, :u, [:p, 10] )
returns self
# File lib/rubabel/molecule.rb, line 44 def add_opts!(type=:gen, *opts) opt_type = OpenBabel::OBConversion.const_get(type.to_s.upcase.<<("OPTIONS")) hash = if opts.first.is_a?(Hash) opts.first else opts.inject({}) do |hsh,v| if v.is_a?(Array) hsh[v[0]] = v[1] else hsh[v] = true end hsh end end hash.each do |k,v| next if v == false args = [ (OUT_OPTS_SHORT[k] || k).to_s, opt_type ] if v && (v != true) args << v end self.add_option(*args) end self end