chemistry-element 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. data/.gitignore +18 -0
  2. data/Gemfile +14 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +29 -0
  5. data/Rakefile +14 -0
  6. data/chemistry-element.gemspec +21 -0
  7. data/lib/chemistry-element/version.rb +5 -0
  8. data/lib/chemistry/element.rb +22 -0
  9. data/lib/chemistry/element/actinium.rb +8 -0
  10. data/lib/chemistry/element/aluminium.rb +8 -0
  11. data/lib/chemistry/element/americium.rb +8 -0
  12. data/lib/chemistry/element/antimony.rb +8 -0
  13. data/lib/chemistry/element/argon.rb +8 -0
  14. data/lib/chemistry/element/arsenic.rb +8 -0
  15. data/lib/chemistry/element/astatine.rb +8 -0
  16. data/lib/chemistry/element/atom.rb +41 -0
  17. data/lib/chemistry/element/barium.rb +8 -0
  18. data/lib/chemistry/element/berkelium.rb +8 -0
  19. data/lib/chemistry/element/beryllium.rb +8 -0
  20. data/lib/chemistry/element/bismuth.rb +8 -0
  21. data/lib/chemistry/element/bohrium.rb +8 -0
  22. data/lib/chemistry/element/boron.rb +8 -0
  23. data/lib/chemistry/element/bromine.rb +8 -0
  24. data/lib/chemistry/element/cadmium.rb +8 -0
  25. data/lib/chemistry/element/caesium.rb +8 -0
  26. data/lib/chemistry/element/calcium.rb +8 -0
  27. data/lib/chemistry/element/californium.rb +8 -0
  28. data/lib/chemistry/element/carbon.rb +8 -0
  29. data/lib/chemistry/element/cerium.rb +8 -0
  30. data/lib/chemistry/element/chlorine.rb +8 -0
  31. data/lib/chemistry/element/chromium.rb +8 -0
  32. data/lib/chemistry/element/cobalt.rb +8 -0
  33. data/lib/chemistry/element/copernicium.rb +8 -0
  34. data/lib/chemistry/element/copper.rb +8 -0
  35. data/lib/chemistry/element/curium.rb +8 -0
  36. data/lib/chemistry/element/darmstadtium.rb +8 -0
  37. data/lib/chemistry/element/dubnium.rb +8 -0
  38. data/lib/chemistry/element/dysprosium.rb +8 -0
  39. data/lib/chemistry/element/einsteinium.rb +8 -0
  40. data/lib/chemistry/element/erbium.rb +8 -0
  41. data/lib/chemistry/element/europium.rb +8 -0
  42. data/lib/chemistry/element/fermium.rb +8 -0
  43. data/lib/chemistry/element/flerovium.rb +8 -0
  44. data/lib/chemistry/element/fluorine.rb +8 -0
  45. data/lib/chemistry/element/francium.rb +8 -0
  46. data/lib/chemistry/element/gadolinium.rb +8 -0
  47. data/lib/chemistry/element/gallium.rb +8 -0
  48. data/lib/chemistry/element/germanium.rb +8 -0
  49. data/lib/chemistry/element/gold.rb +8 -0
  50. data/lib/chemistry/element/hafnium.rb +8 -0
  51. data/lib/chemistry/element/hassium.rb +8 -0
  52. data/lib/chemistry/element/helium.rb +8 -0
  53. data/lib/chemistry/element/holmium.rb +8 -0
  54. data/lib/chemistry/element/hydrogen.rb +8 -0
  55. data/lib/chemistry/element/indium.rb +8 -0
  56. data/lib/chemistry/element/iodine.rb +8 -0
  57. data/lib/chemistry/element/iridium.rb +8 -0
  58. data/lib/chemistry/element/iron.rb +8 -0
  59. data/lib/chemistry/element/krypton.rb +8 -0
  60. data/lib/chemistry/element/lanthanum.rb +8 -0
  61. data/lib/chemistry/element/lawrencium.rb +8 -0
  62. data/lib/chemistry/element/lead.rb +8 -0
  63. data/lib/chemistry/element/lithium.rb +8 -0
  64. data/lib/chemistry/element/livermorium.rb +8 -0
  65. data/lib/chemistry/element/lutetium.rb +8 -0
  66. data/lib/chemistry/element/magnesium.rb +8 -0
  67. data/lib/chemistry/element/manganese.rb +8 -0
  68. data/lib/chemistry/element/meitnerium.rb +8 -0
  69. data/lib/chemistry/element/mendelevium.rb +8 -0
  70. data/lib/chemistry/element/mercury.rb +8 -0
  71. data/lib/chemistry/element/molybdenum.rb +8 -0
  72. data/lib/chemistry/element/neodymium.rb +8 -0
  73. data/lib/chemistry/element/neon.rb +8 -0
  74. data/lib/chemistry/element/neptunium.rb +8 -0
  75. data/lib/chemistry/element/nickel.rb +8 -0
  76. data/lib/chemistry/element/niobium.rb +8 -0
  77. data/lib/chemistry/element/nitrogen.rb +8 -0
  78. data/lib/chemistry/element/nobelium.rb +8 -0
  79. data/lib/chemistry/element/osmium.rb +8 -0
  80. data/lib/chemistry/element/oxygen.rb +8 -0
  81. data/lib/chemistry/element/palladium.rb +8 -0
  82. data/lib/chemistry/element/phosphorus.rb +8 -0
  83. data/lib/chemistry/element/platinum.rb +8 -0
  84. data/lib/chemistry/element/plutonium.rb +8 -0
  85. data/lib/chemistry/element/polonium.rb +8 -0
  86. data/lib/chemistry/element/potassium.rb +8 -0
  87. data/lib/chemistry/element/praseodymium.rb +8 -0
  88. data/lib/chemistry/element/promethium.rb +8 -0
  89. data/lib/chemistry/element/protactinium.rb +8 -0
  90. data/lib/chemistry/element/radium.rb +8 -0
  91. data/lib/chemistry/element/radon.rb +8 -0
  92. data/lib/chemistry/element/rhenium.rb +8 -0
  93. data/lib/chemistry/element/rhodium.rb +8 -0
  94. data/lib/chemistry/element/roentgenium.rb +8 -0
  95. data/lib/chemistry/element/rubidium.rb +8 -0
  96. data/lib/chemistry/element/ruthenium.rb +8 -0
  97. data/lib/chemistry/element/rutherfordium.rb +8 -0
  98. data/lib/chemistry/element/samarium.rb +8 -0
  99. data/lib/chemistry/element/scandium.rb +8 -0
  100. data/lib/chemistry/element/seaborgium.rb +8 -0
  101. data/lib/chemistry/element/selenium.rb +8 -0
  102. data/lib/chemistry/element/silicon.rb +8 -0
  103. data/lib/chemistry/element/silver.rb +8 -0
  104. data/lib/chemistry/element/sodium.rb +8 -0
  105. data/lib/chemistry/element/strontium.rb +8 -0
  106. data/lib/chemistry/element/sulfur.rb +8 -0
  107. data/lib/chemistry/element/tantalum.rb +8 -0
  108. data/lib/chemistry/element/technetium.rb +8 -0
  109. data/lib/chemistry/element/tellurium.rb +8 -0
  110. data/lib/chemistry/element/terbium.rb +8 -0
  111. data/lib/chemistry/element/thallium.rb +8 -0
  112. data/lib/chemistry/element/thorium.rb +8 -0
  113. data/lib/chemistry/element/thulium.rb +8 -0
  114. data/lib/chemistry/element/tin.rb +8 -0
  115. data/lib/chemistry/element/titanium.rb +8 -0
  116. data/lib/chemistry/element/tungsten.rb +8 -0
  117. data/lib/chemistry/element/ununoctium.rb +8 -0
  118. data/lib/chemistry/element/ununpentium.rb +8 -0
  119. data/lib/chemistry/element/ununseptium.rb +8 -0
  120. data/lib/chemistry/element/ununtrium.rb +8 -0
  121. data/lib/chemistry/element/uranium.rb +8 -0
  122. data/lib/chemistry/element/vanadium.rb +8 -0
  123. data/lib/chemistry/element/xenon.rb +8 -0
  124. data/lib/chemistry/element/ytterbium.rb +8 -0
  125. data/lib/chemistry/element/yttrium.rb +8 -0
  126. data/lib/chemistry/element/zinc.rb +8 -0
  127. data/lib/chemistry/element/zirconium.rb +8 -0
  128. data/test/chemistry/element/test_atom.rb +103 -0
  129. data/test/chemistry/test_element.rb +42 -0
  130. data/test/test_chemistry.rb +0 -0
  131. data/test/test_helper.rb +2 -0
  132. metadata +202 -0
@@ -0,0 +1,18 @@
1
+ .rvmrc
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
+ gem 'flog'
5
+ gem 'flay'
6
+
7
+ group :test do
8
+ gem 'minitest'
9
+ gem 'minitest-colorize'
10
+ gem 'pry'
11
+ end
12
+
13
+ # Specify your gem's dependencies in chemistry.gemspec
14
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Isaac Sanders
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Chemistry::Element
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'chemistry-element'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install chemistry-element
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,14 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ LIB_FILES = FileList.new('lib/chemistry/*.rb').
4
+ exclude('lib/chemistry-element/version.rb').
5
+ include('lib/chemistry/element/atom.rb')
6
+ TEST_FILES = LIB_FILES.pathmap('%{^lib,test}d/test_%f')
7
+
8
+ task :test do
9
+ TEST_FILES.zip(LIB_FILES).each do |test_file, lib_file|
10
+ ruby "-I lib -I . -I test -r #{lib_file} #{test_file}"
11
+ end
12
+ end
13
+
14
+ task :default => :test
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'chemistry-element/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "chemistry-element"
8
+ gem.version = Chemistry::Element::VERSION
9
+ gem.authors = ["Isaac Sanders"]
10
+ gem.email = ["isaac@isaacbfsanders.com"]
11
+ gem.description = %q{A library for working with elements}
12
+ gem.summary = %q{A library for working with elements}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency('chemistry-temperature')
21
+ end
@@ -0,0 +1,5 @@
1
+ module Chemistry
2
+ module Element
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,22 @@
1
+ require 'chemistry/element/atom'
2
+
3
+ module Chemistry
4
+ module Element
5
+ extend self
6
+
7
+ def define(name, &definition)
8
+ if block_given?
9
+ create_element_class(name).instance_eval &definition
10
+ else
11
+ raise ArgumentError, "`element` must be given a block"
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def create_element_class(name)
18
+ element_class = Class.new(Chemistry::Element::Atom)
19
+ Chemistry::Element.const_set(name, element_class)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Actinium" do
4
+ symbol "Ac"
5
+ atomic_number 89
6
+ atomic_weight 227
7
+ melting_point '1323K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Aluminium" do
4
+ symbol "Al"
5
+ atomic_number 13
6
+ atomic_weight 26.9815386
7
+ melting_point '933.4K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Americium" do
4
+ symbol "Am"
5
+ atomic_number 95
6
+ atomic_weight 243
7
+ melting_point '1267K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Antimony" do
4
+ symbol "Sb"
5
+ atomic_number 51
6
+ atomic_weight 121.760
7
+ melting_point '904.05K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Argon" do
4
+ symbol "Ar"
5
+ atomic_number 18
6
+ atomic_weight 39.948
7
+ melting_point '83.96K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Arsenic" do
4
+ symbol "As"
5
+ atomic_number 33
6
+ atomic_weight 74.92160
7
+ melting_point '1081K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Astatine" do
4
+ symbol "At"
5
+ atomic_number 85
6
+ atomic_weight 210
7
+ melting_point '575K'
8
+ end
@@ -0,0 +1,41 @@
1
+ require 'chemistry/temperature'
2
+
3
+ module Chemistry
4
+ module Element
5
+ class Atom
6
+ class << self
7
+ def symbol symbol
8
+ const_set :SYMBOL, symbol
9
+ end
10
+
11
+ def atomic_number atomic_number
12
+ const_set :ATOMIC_NUMBER, atomic_number
13
+ end
14
+
15
+ def atomic_weight atomic_weight
16
+ const_set :ATOMIC_WEIGHT, atomic_weight
17
+ end
18
+
19
+ def melting_point melting_point
20
+ const_set :MELTING_POINT, Chemistry::Temperature.parse(melting_point)
21
+ end
22
+ end
23
+
24
+ def symbol
25
+ self.class::SYMBOL
26
+ end
27
+
28
+ def atomic_number
29
+ self.class::ATOMIC_NUMBER
30
+ end
31
+
32
+ def atomic_weight
33
+ self.class::ATOMIC_WEIGHT
34
+ end
35
+
36
+ def melting_point
37
+ self.class::MELTING_POINT
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Barium" do
4
+ symbol "Ba"
5
+ atomic_number 56
6
+ atomic_weight 137.327
7
+ melting_point '1002K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Berkelium" do
4
+ symbol "Bk"
5
+ atomic_number 97
6
+ atomic_weight 247
7
+ melting_point '1259K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Beryllium" do
4
+ symbol "Be"
5
+ atomic_number 4
6
+ atomic_weight 9.012182
7
+ melting_point '1551K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Bismuth" do
4
+ symbol "Bi"
5
+ atomic_number 83
6
+ atomic_weight 208.98040
7
+ melting_point '544.67K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/dsl'
2
+
3
+ Chemistry::DSL.element "Bh" do
4
+ symbol "Bh"
5
+ atomic_number 107
6
+ atomic_weight 264
7
+ melting_point
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Boron" do
4
+ symbol "B"
5
+ atomic_number 5
6
+ atomic_weight 10.811
7
+ melting_point '2573K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Bromine" do
4
+ symbol "Br"
5
+ atomic_number 35
6
+ atomic_weight 79.904
7
+ melting_point '266.05K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Cadmium" do
4
+ symbol "Cd"
5
+ atomic_number 48
6
+ atomic_weight 112.411
7
+ melting_point '594.33K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Caesium" do
4
+ symbol "Cs"
5
+ atomic_number 55
6
+ atomic_weight 132.9054519
7
+ melting_point '301.7K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Calcium" do
4
+ symbol "Ca"
5
+ atomic_number 20
6
+ atomic_weight 40.078
7
+ melting_point '1112K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Californium" do
4
+ symbol "Cf"
5
+ atomic_number 98
6
+ atomic_weight 251
7
+ melting_point '1173K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Carbon" do
4
+ symbol "C"
5
+ atomic_number 6
6
+ atomic_weight 12.0107
7
+ melting_point '3773K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Cerium" do
4
+ symbol "Ce"
5
+ atomic_number 58
6
+ atomic_weight 140.116
7
+ melting_point '1071K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Chlorine" do
4
+ symbol "Cl"
5
+ atomic_number 17
6
+ atomic_weight 35.453
7
+ melting_point '172.31K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Chromium" do
4
+ symbol "Cr"
5
+ atomic_number 24
6
+ atomic_weight 51.9961
7
+ melting_point '2130K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Cobalt" do
4
+ symbol "Co"
5
+ atomic_number 27
6
+ atomic_weight 58.933195
7
+ melting_point '1768K'
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/dsl'
2
+
3
+ Chemistry::DSL.element "Cn" do
4
+ symbol "Cn"
5
+ atomic_number 112
6
+ atomic_weight 285
7
+ melting_point
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Copper" do
4
+ symbol "Cu"
5
+ atomic_number 29
6
+ atomic_weight 63.546
7
+ melting_point '1357.75K'
8
+ end