Sha256: c12e2297dcdc0f767a3d56c7919ba6533c3a2905e24b48e98b5d63478358f6e8

Contents?: true

Size: 471 Bytes

Versions: 6

Compression:

Stored size: 471 Bytes

Contents

module Eulim
  module Chemistry
    # This class is for mixture of compounds/elements
    class Substance
      attr_accessor :species
      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
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
eulim-0.0.17 lib/eulim/chemistry/substance.rb
eulim-0.0.16 lib/eulim/chemistry/substance.rb
eulim-0.0.15 lib/eulim/chemistry/substance.rb
eulim-0.0.14 lib/eulim/chemistry/substance.rb
eulim-0.0.13 lib/eulim/chemistry/substance.rb
eulim-0.0.12 lib/eulim/chemistry/substance.rb