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