class Ilm::Chemistry::Substance

This class is for mixture of compounds/elements

Attributes

species[RW]

Public Class Methods

new(args) click to toggle source
# File lib/ilm/chemistry/substance.rb, line 6
def initialize(args)
  @species = {}
  tt_wt_p = args.inject(0) { |sum, arg| sum + arg.last }
  args.each do |specie, wt_p|
    @species.merge! specie => {
      compound: Compound.new(specie),
      weight_percent: wt_p.to_f / tt_wt_p * 100
    }
  end
end