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,8 @@
1
+ require 'chemistry/element'
2
+
3
+ Chemistry::Element.define "Zirconium" do
4
+ symbol "Zr"
5
+ atomic_number 40
6
+ atomic_weight 91.224
7
+ melting_point '2125K'
8
+ end
@@ -0,0 +1,103 @@
1
+ require 'test_helper'
2
+
3
+ class ElementTestCase < MiniTest::Unit::TestCase
4
+ def element
5
+ @element ||= Class.new(Chemistry::Element::Atom)
6
+ end
7
+ end
8
+
9
+ class ClassLevelAtomicNumberTest < ElementTestCase
10
+ def test_defines_a_constant
11
+ assert_raises NameError do
12
+ element::ATOMIC_NUMBER
13
+ end
14
+
15
+ element.atomic_number 14
16
+
17
+ assert_equal element::ATOMIC_NUMBER, 14
18
+ end
19
+ end
20
+
21
+ class InstanceLevelAtomicNumberTest < ElementTestCase
22
+ def test_requires_atomic_number_to_be_defined_on_the_class_level
23
+ assert_raises NameError do
24
+ element.new.atomic_number
25
+ end
26
+
27
+ element.atomic_number 123
28
+
29
+ assert_equal element.new.atomic_number, 123
30
+ end
31
+ end
32
+
33
+ class ClassLevelAtomicWeightTest < ElementTestCase
34
+ def test_defines_a_constant
35
+ assert_raises NameError do
36
+ element::ATOMIC_WEIGHT
37
+ end
38
+
39
+ element.atomic_weight 1.12342314
40
+
41
+ assert_equal element::ATOMIC_WEIGHT, 1.12342314
42
+ end
43
+ end
44
+
45
+ class InstanceLevelAtomicWeightTest < ElementTestCase
46
+ def test_requires_atomic_weight_to_be_defined_on_the_class_level
47
+ assert_raises NameError do
48
+ element.new.atomic_weight
49
+ end
50
+
51
+ element.atomic_weight 1.12342314
52
+
53
+ assert_equal element.new.atomic_weight, 1.12342314
54
+ end
55
+ end
56
+
57
+ class ClassLevelSymbolTest < ElementTestCase
58
+ def test_defines_a_constant
59
+ assert_raises NameError do
60
+ element::SYMBOL
61
+ end
62
+
63
+ element.symbol "H"
64
+
65
+ assert_equal element::SYMBOL, "H"
66
+ end
67
+ end
68
+
69
+ class InstanceLevelSymbolTest < ElementTestCase
70
+ def test_requires_symbol_to_be_defined_on_the_class_level
71
+ assert_raises NameError do
72
+ element.new.symbol
73
+ end
74
+
75
+ element.symbol 'He'
76
+
77
+ assert_equal element.new.symbol, 'He'
78
+ end
79
+ end
80
+
81
+ class ClassLevelMeltingPointTest < ElementTestCase
82
+ def test_defines_a_constant
83
+ assert_raises NameError do
84
+ element::MELTING_POINT
85
+ end
86
+
87
+ element.melting_point "1K"
88
+
89
+ assert_equal element::MELTING_POINT, Chemistry::Temperature.parse("1k")
90
+ end
91
+ end
92
+
93
+ class InstanceLevelMeltingPointTest < ElementTestCase
94
+ def test_requires_symbol_to_be_defined_on_the_class_level
95
+ assert_raises NameError do
96
+ element.new.melting_point
97
+ end
98
+
99
+ element.melting_point '1K'
100
+
101
+ assert_equal element.new.melting_point, Chemistry::Temperature.parse('1K')
102
+ end
103
+ end
@@ -0,0 +1,42 @@
1
+ require 'test_helper'
2
+
3
+ class ElementTest < MiniTest::Unit::TestCase
4
+ def test_raises_error_without_name
5
+ assert_raises ArgumentError do
6
+ Chemistry::Element.define
7
+ end
8
+ end
9
+
10
+ def test_raises_error_without_block
11
+ assert_raises ArgumentError do
12
+ Chemistry::Element.define "Hydrogen"
13
+ end
14
+ end
15
+
16
+ def test_defines_an_element
17
+ assert_raises NameError do
18
+ Chemistry::Element::Foobar
19
+ end
20
+
21
+ Chemistry::Element.define "Foobar" do
22
+ end
23
+
24
+ assert_equal Chemistry::Element::Atom <=> Chemistry::Element::Foobar, 1
25
+ end
26
+ end
27
+
28
+ class DefinitionTest < MiniTest::Unit::TestCase
29
+
30
+ def test_full_definition
31
+ Chemistry::Element.define "Hydrogen" do
32
+ symbol 'H'
33
+ atomic_number 1
34
+ atomic_weight 1.00794
35
+ end
36
+
37
+ h_atom = Chemistry::Element::Hydrogen.new
38
+
39
+ assert_equal h_atom.symbol, 'H'
40
+ assert_equal h_atom.atomic_number, 1
41
+ end
42
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/colorize'
metadata ADDED
@@ -0,0 +1,202 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chemistry-element
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Isaac Sanders
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: chemistry-temperature
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: A library for working with elements
31
+ email:
32
+ - isaac@isaacbfsanders.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - chemistry-element.gemspec
43
+ - lib/chemistry-element/version.rb
44
+ - lib/chemistry/element.rb
45
+ - lib/chemistry/element/actinium.rb
46
+ - lib/chemistry/element/aluminium.rb
47
+ - lib/chemistry/element/americium.rb
48
+ - lib/chemistry/element/antimony.rb
49
+ - lib/chemistry/element/argon.rb
50
+ - lib/chemistry/element/arsenic.rb
51
+ - lib/chemistry/element/astatine.rb
52
+ - lib/chemistry/element/atom.rb
53
+ - lib/chemistry/element/barium.rb
54
+ - lib/chemistry/element/berkelium.rb
55
+ - lib/chemistry/element/beryllium.rb
56
+ - lib/chemistry/element/bismuth.rb
57
+ - lib/chemistry/element/bohrium.rb
58
+ - lib/chemistry/element/boron.rb
59
+ - lib/chemistry/element/bromine.rb
60
+ - lib/chemistry/element/cadmium.rb
61
+ - lib/chemistry/element/caesium.rb
62
+ - lib/chemistry/element/calcium.rb
63
+ - lib/chemistry/element/californium.rb
64
+ - lib/chemistry/element/carbon.rb
65
+ - lib/chemistry/element/cerium.rb
66
+ - lib/chemistry/element/chlorine.rb
67
+ - lib/chemistry/element/chromium.rb
68
+ - lib/chemistry/element/cobalt.rb
69
+ - lib/chemistry/element/copernicium.rb
70
+ - lib/chemistry/element/copper.rb
71
+ - lib/chemistry/element/curium.rb
72
+ - lib/chemistry/element/darmstadtium.rb
73
+ - lib/chemistry/element/dubnium.rb
74
+ - lib/chemistry/element/dysprosium.rb
75
+ - lib/chemistry/element/einsteinium.rb
76
+ - lib/chemistry/element/erbium.rb
77
+ - lib/chemistry/element/europium.rb
78
+ - lib/chemistry/element/fermium.rb
79
+ - lib/chemistry/element/flerovium.rb
80
+ - lib/chemistry/element/fluorine.rb
81
+ - lib/chemistry/element/francium.rb
82
+ - lib/chemistry/element/gadolinium.rb
83
+ - lib/chemistry/element/gallium.rb
84
+ - lib/chemistry/element/germanium.rb
85
+ - lib/chemistry/element/gold.rb
86
+ - lib/chemistry/element/hafnium.rb
87
+ - lib/chemistry/element/hassium.rb
88
+ - lib/chemistry/element/helium.rb
89
+ - lib/chemistry/element/holmium.rb
90
+ - lib/chemistry/element/hydrogen.rb
91
+ - lib/chemistry/element/indium.rb
92
+ - lib/chemistry/element/iodine.rb
93
+ - lib/chemistry/element/iridium.rb
94
+ - lib/chemistry/element/iron.rb
95
+ - lib/chemistry/element/krypton.rb
96
+ - lib/chemistry/element/lanthanum.rb
97
+ - lib/chemistry/element/lawrencium.rb
98
+ - lib/chemistry/element/lead.rb
99
+ - lib/chemistry/element/lithium.rb
100
+ - lib/chemistry/element/livermorium.rb
101
+ - lib/chemistry/element/lutetium.rb
102
+ - lib/chemistry/element/magnesium.rb
103
+ - lib/chemistry/element/manganese.rb
104
+ - lib/chemistry/element/meitnerium.rb
105
+ - lib/chemistry/element/mendelevium.rb
106
+ - lib/chemistry/element/mercury.rb
107
+ - lib/chemistry/element/molybdenum.rb
108
+ - lib/chemistry/element/neodymium.rb
109
+ - lib/chemistry/element/neon.rb
110
+ - lib/chemistry/element/neptunium.rb
111
+ - lib/chemistry/element/nickel.rb
112
+ - lib/chemistry/element/niobium.rb
113
+ - lib/chemistry/element/nitrogen.rb
114
+ - lib/chemistry/element/nobelium.rb
115
+ - lib/chemistry/element/osmium.rb
116
+ - lib/chemistry/element/oxygen.rb
117
+ - lib/chemistry/element/palladium.rb
118
+ - lib/chemistry/element/phosphorus.rb
119
+ - lib/chemistry/element/platinum.rb
120
+ - lib/chemistry/element/plutonium.rb
121
+ - lib/chemistry/element/polonium.rb
122
+ - lib/chemistry/element/potassium.rb
123
+ - lib/chemistry/element/praseodymium.rb
124
+ - lib/chemistry/element/promethium.rb
125
+ - lib/chemistry/element/protactinium.rb
126
+ - lib/chemistry/element/radium.rb
127
+ - lib/chemistry/element/radon.rb
128
+ - lib/chemistry/element/rhenium.rb
129
+ - lib/chemistry/element/rhodium.rb
130
+ - lib/chemistry/element/roentgenium.rb
131
+ - lib/chemistry/element/rubidium.rb
132
+ - lib/chemistry/element/ruthenium.rb
133
+ - lib/chemistry/element/rutherfordium.rb
134
+ - lib/chemistry/element/samarium.rb
135
+ - lib/chemistry/element/scandium.rb
136
+ - lib/chemistry/element/seaborgium.rb
137
+ - lib/chemistry/element/selenium.rb
138
+ - lib/chemistry/element/silicon.rb
139
+ - lib/chemistry/element/silver.rb
140
+ - lib/chemistry/element/sodium.rb
141
+ - lib/chemistry/element/strontium.rb
142
+ - lib/chemistry/element/sulfur.rb
143
+ - lib/chemistry/element/tantalum.rb
144
+ - lib/chemistry/element/technetium.rb
145
+ - lib/chemistry/element/tellurium.rb
146
+ - lib/chemistry/element/terbium.rb
147
+ - lib/chemistry/element/thallium.rb
148
+ - lib/chemistry/element/thorium.rb
149
+ - lib/chemistry/element/thulium.rb
150
+ - lib/chemistry/element/tin.rb
151
+ - lib/chemistry/element/titanium.rb
152
+ - lib/chemistry/element/tungsten.rb
153
+ - lib/chemistry/element/ununoctium.rb
154
+ - lib/chemistry/element/ununpentium.rb
155
+ - lib/chemistry/element/ununseptium.rb
156
+ - lib/chemistry/element/ununtrium.rb
157
+ - lib/chemistry/element/uranium.rb
158
+ - lib/chemistry/element/vanadium.rb
159
+ - lib/chemistry/element/xenon.rb
160
+ - lib/chemistry/element/ytterbium.rb
161
+ - lib/chemistry/element/yttrium.rb
162
+ - lib/chemistry/element/zinc.rb
163
+ - lib/chemistry/element/zirconium.rb
164
+ - test/chemistry/element/test_atom.rb
165
+ - test/chemistry/test_element.rb
166
+ - test/test_chemistry.rb
167
+ - test/test_helper.rb
168
+ homepage: ''
169
+ licenses: []
170
+ post_install_message:
171
+ rdoc_options: []
172
+ require_paths:
173
+ - lib
174
+ required_ruby_version: !ruby/object:Gem::Requirement
175
+ none: false
176
+ requirements:
177
+ - - ! '>='
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ segments:
181
+ - 0
182
+ hash: 1546364600133193151
183
+ required_rubygems_version: !ruby/object:Gem::Requirement
184
+ none: false
185
+ requirements:
186
+ - - ! '>='
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ segments:
190
+ - 0
191
+ hash: 1546364600133193151
192
+ requirements: []
193
+ rubyforge_project:
194
+ rubygems_version: 1.8.24
195
+ signing_key:
196
+ specification_version: 3
197
+ summary: A library for working with elements
198
+ test_files:
199
+ - test/chemistry/element/test_atom.rb
200
+ - test/chemistry/test_element.rb
201
+ - test/test_chemistry.rb
202
+ - test/test_helper.rb