lib/eulim/chemistry/compound.rb in eulim-0.0.3 vs lib/eulim/chemistry/compound.rb in eulim-0.0.4
- old
+ new
@@ -1,15 +1,31 @@
+module Eulim::Chemistry
+ class Compound
+ def initialize(arg)
+ @formula = arg
+ end
+
+ def constituent_elements
+ elements = []
+ @formula.split(/(?=[A-Z])/).each do |element_symbol|
+ elements << Element.get_by_symbol(element_symbol.gsub(/(\W|\d)/, ""))
+ end
+ elements
+ end
+
+ end
+end
\ No newline at end of file