elementic 0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/elementic.rb +197 -0
  3. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4fde8a77607fed61af08cf7cacc2f5eb638125ce
4
+ data.tar.gz: 1511f4d9aa4407f0207c0bef29b3c8711b38512c
5
+ SHA512:
6
+ metadata.gz: 28bd2f97d5710b5cbce10d14b6d763a0909aa48326498cb83f312d625e992bf355cb82822a3dd86f2cd493fe9d88c7cc0e53fe821ba80e7bc15fd4807867d698
7
+ data.tar.gz: 061fae76554e0504da3734fd39a04da28ea0c98eeba9c05ede3163deea16bb82c049624129d3e3bb0f00234c3401e9a4e219da8aa717e1853b4e8201fd7d9ed2
@@ -0,0 +1,197 @@
1
+ #!/usr/bin/env ruby
2
+ VERSION = '0.6'
3
+
4
+ $elements = {
5
+ 'H' => 'Hyrdogen',
6
+ 'Li' => 'Lithium',
7
+ 'He' => 'Helium',
8
+ 'Be' => 'Beryliium',
9
+ 'B' => 'Boron',
10
+ 'C' => 'Carbon',
11
+ 'N' => 'Nitrogen',
12
+ 'O' => 'Oxygen',
13
+ 'F' => 'Fluorine',
14
+ 'Ne' => 'Neon',
15
+ 'Na' => 'Sodium',
16
+ 'Mg' => 'Magnesium',
17
+ 'Al' => 'Aluminum',
18
+ 'Si' => 'Silicon',
19
+ 'P' => 'Phosphorus',
20
+ 'S' => 'Sulfur',
21
+ 'Cl' => 'Chlorine',
22
+ 'Ar' => 'Argon',
23
+ 'K' => 'Potassium',
24
+ 'Ca' => 'Calcium',
25
+ 'Sc' => 'Scandium',
26
+ 'Ti' => 'Titanium',
27
+ 'V' => 'Vanadium',
28
+ 'Cr' => 'Chromium',
29
+ 'Mn' => 'Manganese',
30
+ 'Fe' => 'Iron',
31
+ 'Co' => 'Cobalt',
32
+ 'Ni' => 'Nickel',
33
+ 'Cu' => 'Copper',
34
+ 'Zn' => 'Zinc',
35
+ 'Ga' => 'Gallium',
36
+ 'Ge' => 'Germanium',
37
+ 'As' => 'Arsenic',
38
+ 'Se' => 'Selenium',
39
+ 'Br' => 'Bromine',
40
+ 'Kr' => 'Krypton',
41
+ 'Rb' => 'Rubidium',
42
+ 'Sr' => 'Strontium',
43
+ 'Y' => 'Yttrium',
44
+ 'Zr' => 'Zirconium',
45
+ 'Nb' => 'Niobium',
46
+ 'Mo' => 'Molybdenum',
47
+ 'Tc' => 'Technetium',
48
+ 'Ru' => 'Ruthenium',
49
+ 'Rh' => 'Rhodium',
50
+ 'Pd' => 'Palladium',
51
+ 'Ag' => 'Silver',
52
+ 'Cd' => 'Cadmium',
53
+ 'In' => 'Indium',
54
+ 'Sn' => 'Tin',
55
+ 'Sb' => 'Antimony',
56
+ 'Te' => 'Tellurium',
57
+ 'I' => 'Iodine',
58
+ 'Xe' => 'Xenon',
59
+ 'Cs' => 'Cesium',
60
+ 'Ba' => 'Barium',
61
+ 'La' => 'Lanthanum',
62
+ 'Ce' => 'Cerium',
63
+ 'Pr' => 'Praseodymium',
64
+ 'Nd' => 'Neodymium',
65
+ 'Pm' => 'Promethium',
66
+ 'Sm' => 'Samarium',
67
+ 'Eu' => 'Europium',
68
+ 'Gd' => 'Gadolinium',
69
+ 'Tb' => 'Terbium',
70
+ 'Dy' => 'Dysprosium',
71
+ 'Ho' => 'Holmium',
72
+ 'Er' => 'Erbium',
73
+ 'Tm' => 'Thulium',
74
+ 'Yb' => 'Ytterbium',
75
+ 'Lu' => 'Lutetium',
76
+ 'Hf' => 'Hafnium',
77
+ 'Ta' => 'Tantalum',
78
+ 'W' => 'Tungsten',
79
+ 'Re' => 'Rhenium',
80
+ 'Os' => 'Osmium',
81
+ 'Ir' => 'Iridium',
82
+ 'Pt' => 'Platinum',
83
+ 'Au' => 'Gold',
84
+ 'Hg' => 'Mercury',
85
+ 'Tl' => 'Thallium',
86
+ 'Pb' => 'Lead',
87
+ 'Bi' => 'Bismuth',
88
+ 'Po' => 'Polonium',
89
+ 'At' => 'Astatine',
90
+ 'Rn' => 'Radon',
91
+ 'Fr' => 'Francium',
92
+ 'Ra' => 'Radium',
93
+ 'Ac' => 'Actinium',
94
+ 'Th' => 'Thorium',
95
+ 'Pa' => 'Protactinium',
96
+ 'U' => 'Uranium',
97
+ 'Np' => 'Neptunium',
98
+ 'Pu' => 'Plutonium',
99
+ 'Am' => 'Americium',
100
+ 'Cm' => 'Curium',
101
+ 'Bk' => 'Berkelium',
102
+ 'Cf' => 'Californium',
103
+ 'Es' => 'Einsteinium',
104
+ 'Fm' => 'Fermium',
105
+ 'Md' => 'Mendelevium',
106
+ 'No' => 'Nobelium',
107
+ 'Lr' => 'Lawrencium',
108
+ 'Rf' => 'Rutherfordium',
109
+ 'Db' => 'Dubnium',
110
+ 'Sg' => 'Seaborgium',
111
+ 'Bh' => 'Bohrium',
112
+ 'Hs' => 'Hassium',
113
+ 'Mt' => 'Meitnerium'
114
+ }
115
+
116
+ # Define some extra methods for class String
117
+ class String
118
+
119
+ # Return true or false depending on
120
+ #if the element symbol exists
121
+ def element?
122
+ input = self.capitalize
123
+ if $elements[input].nil?
124
+ return false
125
+ else
126
+ return true
127
+ end
128
+ end
129
+
130
+ # Use element? method to convert an
131
+ # element symbol into its name
132
+ def element
133
+ input = self.capitalize
134
+ if input.element?
135
+ puts $elements[input]
136
+ else
137
+ puts "'#{input}' is not an element symbol"
138
+ end
139
+ end
140
+
141
+ # Use the element? method to check if
142
+ # a string (that contains other words)
143
+ # contains element symbols
144
+ def contains_element?
145
+ input = self.capitalize
146
+ new = input.split ' '
147
+ $thing = 0
148
+ new.each do |i|
149
+ if i.element?
150
+ $thing += 1
151
+ end
152
+ end
153
+ if $thing > 0
154
+ return true
155
+ else
156
+ return false
157
+ end
158
+ end
159
+ end
160
+
161
+ # Use the element? method to convert
162
+ # all symbols into the element name
163
+
164
+ # try getting this to work
165
+
166
+ # def convert_all
167
+ # input = self.capitalize
168
+ # if input.element?
169
+ # $new = input.split ' '
170
+ # end
171
+ # $new.each do |i|
172
+ # $elements.each do |e|
173
+ # if i == e
174
+ # $new.gsub(i, e)
175
+ # end
176
+ # end
177
+ # end
178
+ # puts $new.join ' '
179
+ # end
180
+ # end
181
+
182
+ # Create some methods for the Elementic class
183
+ class Elementic
184
+ # Elementic.version will `puts` the version
185
+ def self.version
186
+ puts "elementic v#{VERSION}"
187
+ end
188
+
189
+ def self.list
190
+ $elements.each do |i|
191
+ puts i
192
+ puts
193
+ end
194
+ return $elements.length
195
+ end
196
+
197
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: elementic
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.6'
5
+ platform: ruby
6
+ authors:
7
+ - Josh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A usable hash of the Periodic table of elements
14
+ email: joshception@icloud.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/elementic.rb
20
+ homepage: http://rubygems.org/gems/elementic
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.2.2
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Easier chemistry
44
+ test_files: []