Class: OpenBabel::OBConversion
Constant Summary collapse
- OUT_OPTS_SHORT =
{ no_element_coloring: :u, no_internal_specified_color: :U, black_bkg: :b, no_terminal_c: :C, draw_all_carbon: :a, no_molecule_name: :d, embed_mol_as_cml: :e, scale_to_bondlength_pixels: :p, size: :P, # single number of pixels (e.g., 300, but will take dims for png: ('300x250')) add_atom_index: :i, no_javascript: :j, wedge_hash_bonds: :w, no_xml_declaration: :x, aliases: :A, }
Instance Method Summary collapse
-
#add_opts!(type = :gen, *opts) ⇒ Object
adds the opts to the type, where type is :gen, :out, or :in.
Instance Method Details
#add_opts!(type = :gen, *opts) ⇒ Object
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
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rubabel/molecule.rb', line 43 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 |