chemistry-element 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +14 -0
- data/chemistry-element.gemspec +21 -0
- data/lib/chemistry-element/version.rb +5 -0
- data/lib/chemistry/element.rb +22 -0
- data/lib/chemistry/element/actinium.rb +8 -0
- data/lib/chemistry/element/aluminium.rb +8 -0
- data/lib/chemistry/element/americium.rb +8 -0
- data/lib/chemistry/element/antimony.rb +8 -0
- data/lib/chemistry/element/argon.rb +8 -0
- data/lib/chemistry/element/arsenic.rb +8 -0
- data/lib/chemistry/element/astatine.rb +8 -0
- data/lib/chemistry/element/atom.rb +41 -0
- data/lib/chemistry/element/barium.rb +8 -0
- data/lib/chemistry/element/berkelium.rb +8 -0
- data/lib/chemistry/element/beryllium.rb +8 -0
- data/lib/chemistry/element/bismuth.rb +8 -0
- data/lib/chemistry/element/bohrium.rb +8 -0
- data/lib/chemistry/element/boron.rb +8 -0
- data/lib/chemistry/element/bromine.rb +8 -0
- data/lib/chemistry/element/cadmium.rb +8 -0
- data/lib/chemistry/element/caesium.rb +8 -0
- data/lib/chemistry/element/calcium.rb +8 -0
- data/lib/chemistry/element/californium.rb +8 -0
- data/lib/chemistry/element/carbon.rb +8 -0
- data/lib/chemistry/element/cerium.rb +8 -0
- data/lib/chemistry/element/chlorine.rb +8 -0
- data/lib/chemistry/element/chromium.rb +8 -0
- data/lib/chemistry/element/cobalt.rb +8 -0
- data/lib/chemistry/element/copernicium.rb +8 -0
- data/lib/chemistry/element/copper.rb +8 -0
- data/lib/chemistry/element/curium.rb +8 -0
- data/lib/chemistry/element/darmstadtium.rb +8 -0
- data/lib/chemistry/element/dubnium.rb +8 -0
- data/lib/chemistry/element/dysprosium.rb +8 -0
- data/lib/chemistry/element/einsteinium.rb +8 -0
- data/lib/chemistry/element/erbium.rb +8 -0
- data/lib/chemistry/element/europium.rb +8 -0
- data/lib/chemistry/element/fermium.rb +8 -0
- data/lib/chemistry/element/flerovium.rb +8 -0
- data/lib/chemistry/element/fluorine.rb +8 -0
- data/lib/chemistry/element/francium.rb +8 -0
- data/lib/chemistry/element/gadolinium.rb +8 -0
- data/lib/chemistry/element/gallium.rb +8 -0
- data/lib/chemistry/element/germanium.rb +8 -0
- data/lib/chemistry/element/gold.rb +8 -0
- data/lib/chemistry/element/hafnium.rb +8 -0
- data/lib/chemistry/element/hassium.rb +8 -0
- data/lib/chemistry/element/helium.rb +8 -0
- data/lib/chemistry/element/holmium.rb +8 -0
- data/lib/chemistry/element/hydrogen.rb +8 -0
- data/lib/chemistry/element/indium.rb +8 -0
- data/lib/chemistry/element/iodine.rb +8 -0
- data/lib/chemistry/element/iridium.rb +8 -0
- data/lib/chemistry/element/iron.rb +8 -0
- data/lib/chemistry/element/krypton.rb +8 -0
- data/lib/chemistry/element/lanthanum.rb +8 -0
- data/lib/chemistry/element/lawrencium.rb +8 -0
- data/lib/chemistry/element/lead.rb +8 -0
- data/lib/chemistry/element/lithium.rb +8 -0
- data/lib/chemistry/element/livermorium.rb +8 -0
- data/lib/chemistry/element/lutetium.rb +8 -0
- data/lib/chemistry/element/magnesium.rb +8 -0
- data/lib/chemistry/element/manganese.rb +8 -0
- data/lib/chemistry/element/meitnerium.rb +8 -0
- data/lib/chemistry/element/mendelevium.rb +8 -0
- data/lib/chemistry/element/mercury.rb +8 -0
- data/lib/chemistry/element/molybdenum.rb +8 -0
- data/lib/chemistry/element/neodymium.rb +8 -0
- data/lib/chemistry/element/neon.rb +8 -0
- data/lib/chemistry/element/neptunium.rb +8 -0
- data/lib/chemistry/element/nickel.rb +8 -0
- data/lib/chemistry/element/niobium.rb +8 -0
- data/lib/chemistry/element/nitrogen.rb +8 -0
- data/lib/chemistry/element/nobelium.rb +8 -0
- data/lib/chemistry/element/osmium.rb +8 -0
- data/lib/chemistry/element/oxygen.rb +8 -0
- data/lib/chemistry/element/palladium.rb +8 -0
- data/lib/chemistry/element/phosphorus.rb +8 -0
- data/lib/chemistry/element/platinum.rb +8 -0
- data/lib/chemistry/element/plutonium.rb +8 -0
- data/lib/chemistry/element/polonium.rb +8 -0
- data/lib/chemistry/element/potassium.rb +8 -0
- data/lib/chemistry/element/praseodymium.rb +8 -0
- data/lib/chemistry/element/promethium.rb +8 -0
- data/lib/chemistry/element/protactinium.rb +8 -0
- data/lib/chemistry/element/radium.rb +8 -0
- data/lib/chemistry/element/radon.rb +8 -0
- data/lib/chemistry/element/rhenium.rb +8 -0
- data/lib/chemistry/element/rhodium.rb +8 -0
- data/lib/chemistry/element/roentgenium.rb +8 -0
- data/lib/chemistry/element/rubidium.rb +8 -0
- data/lib/chemistry/element/ruthenium.rb +8 -0
- data/lib/chemistry/element/rutherfordium.rb +8 -0
- data/lib/chemistry/element/samarium.rb +8 -0
- data/lib/chemistry/element/scandium.rb +8 -0
- data/lib/chemistry/element/seaborgium.rb +8 -0
- data/lib/chemistry/element/selenium.rb +8 -0
- data/lib/chemistry/element/silicon.rb +8 -0
- data/lib/chemistry/element/silver.rb +8 -0
- data/lib/chemistry/element/sodium.rb +8 -0
- data/lib/chemistry/element/strontium.rb +8 -0
- data/lib/chemistry/element/sulfur.rb +8 -0
- data/lib/chemistry/element/tantalum.rb +8 -0
- data/lib/chemistry/element/technetium.rb +8 -0
- data/lib/chemistry/element/tellurium.rb +8 -0
- data/lib/chemistry/element/terbium.rb +8 -0
- data/lib/chemistry/element/thallium.rb +8 -0
- data/lib/chemistry/element/thorium.rb +8 -0
- data/lib/chemistry/element/thulium.rb +8 -0
- data/lib/chemistry/element/tin.rb +8 -0
- data/lib/chemistry/element/titanium.rb +8 -0
- data/lib/chemistry/element/tungsten.rb +8 -0
- data/lib/chemistry/element/ununoctium.rb +8 -0
- data/lib/chemistry/element/ununpentium.rb +8 -0
- data/lib/chemistry/element/ununseptium.rb +8 -0
- data/lib/chemistry/element/ununtrium.rb +8 -0
- data/lib/chemistry/element/uranium.rb +8 -0
- data/lib/chemistry/element/vanadium.rb +8 -0
- data/lib/chemistry/element/xenon.rb +8 -0
- data/lib/chemistry/element/ytterbium.rb +8 -0
- data/lib/chemistry/element/yttrium.rb +8 -0
- data/lib/chemistry/element/zinc.rb +8 -0
- data/lib/chemistry/element/zirconium.rb +8 -0
- data/test/chemistry/element/test_atom.rb +103 -0
- data/test/chemistry/test_element.rb +42 -0
- data/test/test_chemistry.rb +0 -0
- data/test/test_helper.rb +2 -0
- metadata +202 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -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.
|
data/README.md
ADDED
@@ -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
|
data/Rakefile
ADDED
@@ -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,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,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
|