chemical_elements 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7cab90413b69302c2b05d1619c40c30a861d0ca875dbcc75946b384124a2b7e9
4
+ data.tar.gz: 764adbfb3432ff9a8f81211bd4ac3fbaa6d4dac2ac607ca672750dd5ce6b6c7d
5
+ SHA512:
6
+ metadata.gz: 47a47262260db0e192fd233d0af9246e473f2eeed13cd6a5e50a55273d0aa9e403516135ea1c074d186a5a2887bd99cfa669c7e6cc4f7d98597c56236db8597e
7
+ data.tar.gz: 3ee044af9763bf7bb794a62e1c29d49612268845d2b58ff438ace2e48c78ddf8ed71aa7e751ee9471f9e0c0a5f219a832839c6c5fe0c2f7f0e4240d224ed2990
@@ -0,0 +1,35 @@
1
+ # Ruby CircleCI 2.0 configuration file
2
+ #
3
+ # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
+ #
5
+ version: 2
6
+ jobs:
7
+ build:
8
+ docker:
9
+ # specify the version you desire here
10
+ - image: circleci/ruby:2.6.3
11
+
12
+ working_directory: ~/repo
13
+
14
+ steps:
15
+ - checkout
16
+ - run:
17
+ name: install dependencies
18
+ command: gem install bundler -v 2.0.2
19
+
20
+ - run:
21
+ name: install dependencies
22
+ command: |
23
+ bundle install
24
+
25
+ # run tests!
26
+ - run:
27
+ name: run tests
28
+ command: |
29
+ bundle exec rspec
30
+
31
+ # run rubocop!
32
+ - run:
33
+ name: run rubocop
34
+ command: |
35
+ bundle exec rubocop
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,12 @@
1
+ Metrics/BlockLength:
2
+ Exclude:
3
+ - "spec/**/*.rb"
4
+
5
+ Style/FrozenStringLiteralComment:
6
+ Enabled: false
7
+
8
+ LineLength:
9
+ Max: 90
10
+
11
+ Style/Documentation:
12
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.3
7
+ before_install: gem install bundler -v 2.0.2
data/CHANGELOG.md ADDED
File without changes
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at hajiwata0308@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in chemical_elements.gemspec
6
+ gemspec
7
+ gem 'rubocop'
data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ chemical_elements (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.0)
10
+ diff-lcs (1.3)
11
+ jaro_winkler (1.5.3)
12
+ parallel (1.17.0)
13
+ parser (2.6.4.1)
14
+ ast (~> 2.4.0)
15
+ rainbow (3.0.0)
16
+ rake (10.5.0)
17
+ rspec (3.8.0)
18
+ rspec-core (~> 3.8.0)
19
+ rspec-expectations (~> 3.8.0)
20
+ rspec-mocks (~> 3.8.0)
21
+ rspec-core (3.8.2)
22
+ rspec-support (~> 3.8.0)
23
+ rspec-expectations (3.8.4)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.8.0)
26
+ rspec-mocks (3.8.1)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.8.0)
29
+ rspec-support (3.8.2)
30
+ rubocop (0.74.0)
31
+ jaro_winkler (~> 1.5.1)
32
+ parallel (~> 1.10)
33
+ parser (>= 2.6)
34
+ rainbow (>= 2.2.2, < 4.0)
35
+ ruby-progressbar (~> 1.7)
36
+ unicode-display_width (>= 1.4.0, < 1.7)
37
+ ruby-progressbar (1.10.1)
38
+ unicode-display_width (1.6.0)
39
+
40
+ PLATFORMS
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ bundler (~> 2.0)
45
+ chemical_elements!
46
+ rake (~> 10.0)
47
+ rspec (~> 3.0)
48
+ rubocop
49
+
50
+ BUNDLED WITH
51
+ 2.0.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 hatsu38
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # ChemicalElements
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'chemical_elements'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install chemical_elements
18
+
19
+ ## Usage
20
+
21
+ ### Load Library
22
+ ```
23
+ require 'chemical_elements'
24
+ ```
25
+
26
+ ### Seach by chemical element symbol
27
+ ```
28
+ element = ChemicalElements::PeriodicTable.find('H')
29
+ # => #<ChemicalElements::PeriodicTable:0x00007fb2f3059490 @name="Hydrogen", @symbol="H", @atomic_num=1, @atomic_amount=1.00798>
30
+
31
+ element.name
32
+ # => "Hydrogen"
33
+
34
+ element.symbol
35
+ # => "H"
36
+
37
+ element.atomic_num
38
+ # => 1
39
+
40
+ element.atomic_amount
41
+ # => 1.00798
42
+ ```
43
+
44
+ ### Search by chemical element name and symbol, atomic_num, atomic_amount
45
+ ```
46
+ ChemicalElements::PeriodicTable.find_by(name: 'Hydrogen')
47
+ ChemicalElements::PeriodicTable.find_by(symbol: 'H')
48
+ ChemicalElements::PeriodicTable.find_by(atomic_num: 1)
49
+ ChemicalElements::PeriodicTable.find_by(atomic_amount: 1.00798)
50
+ ```
51
+
52
+ ## Development
53
+
54
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
55
+
56
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
57
+
58
+ ## Contributing
59
+
60
+ Bug reports and pull requests are welcome on GitHub at https://github.com/hatsu38/chemical_elements. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
61
+
62
+ ## License
63
+
64
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
65
+
66
+ ## Code of Conduct
67
+
68
+ Everyone interacting in the ChemicalElements project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/chemical_elements/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'chemical_elements'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'chemical_elements/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'chemical_elements'
9
+ spec.version = ChemicalElements::VERSION
10
+ spec.authors = ['hatsu38']
11
+ spec.email = ['hajiwata0308@gmail.com']
12
+
13
+ spec.summary = 'Provide chemical element list data based on the periodic table.'
14
+ spec.description = 'Provide chemical element list data based on the periodic table.'
15
+ spec.homepage = 'https://github.com/hatsu38/chemical_elements'
16
+ spec.license = 'MIT'
17
+
18
+ spec.metadata['homepage_uri'] = spec.homepage
19
+ spec.metadata['source_code_uri'] = 'https://github.com/hatsu38/chemical_elements'
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = 'exe'
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.add_development_dependency 'bundler', '~> 2.0'
30
+ spec.add_development_dependency 'rake', '~> 10.0'
31
+ spec.add_development_dependency 'rspec', '~> 3.0'
32
+ end
@@ -0,0 +1,590 @@
1
+ 1:
2
+ :name: Hydrogen
3
+ :symbol: H
4
+ :atomic_num: 1
5
+ :atomic_amount: 1.00798
6
+ 2:
7
+ :name: Helium
8
+ :symbol: He
9
+ :atomic_num: 2
10
+ :atomic_amount: 4.0026
11
+ 3:
12
+ :name: Lithium
13
+ :symbol: Li
14
+ :atomic_num: 3
15
+ :atomic_amount: 6.968
16
+ 4:
17
+ :name: Berylium
18
+ :symbol: Be
19
+ :atomic_num: 4
20
+ :atomic_amount: 9.01218
21
+ 5:
22
+ :name: Boron
23
+ :symbol: B
24
+ :atomic_num: 5
25
+ :atomic_amount: 10.814
26
+ 6:
27
+ :name: Carbon
28
+ :symbol: C
29
+ :atomic_num: 6
30
+ :atomic_amount: 12.0106
31
+ 7:
32
+ :name: Nitrogen
33
+ :symbol: N
34
+ :atomic_num: 7
35
+ :atomic_amount: 14.0069
36
+ 8:
37
+ :name: Oxygen
38
+ :symbol: O
39
+ :atomic_num: 8
40
+ :atomic_amount: 15.9994
41
+ 9:
42
+ :name: Fluorine
43
+ :symbol: F
44
+ :atomic_num: 9
45
+ :atomic_amount: 28.397
46
+ 10:
47
+ :name: Neon
48
+ :symbol: Ne
49
+ :atomic_num: 10
50
+ :atomic_amount: 20.1797
51
+ 11:
52
+ :name: Sodium
53
+ :symbol: Na
54
+ :atomic_num: 11
55
+ :atomic_amount: 22.9898
56
+ 12:
57
+ :name: Magnessium
58
+ :symbol: Mg
59
+ :atomic_num: 12
60
+ :atomic_amount: 24.306
61
+ 13:
62
+ :name: Aluminum
63
+ :symbol: Al
64
+ :atomic_num: 13
65
+ :atomic_amount: 26.9815
66
+ 14:
67
+ :name: Silicon
68
+ :symbol: Si
69
+ :atomic_num: 14
70
+ :atomic_amount: 28.085
71
+ 15:
72
+ :name: Phosphorus
73
+ :symbol: P
74
+ :atomic_num: 15
75
+ :atomic_amount: 30.9738
76
+ 16:
77
+ :name: Sulfur
78
+ :symbol: S
79
+ :atomic_num: 16
80
+ :atomic_amount: 32.068
81
+ 17:
82
+ :name: Chlorine
83
+ :symbol: Cl
84
+ :atomic_num: 17
85
+ :atomic_amount: 35.452
86
+ 18:
87
+ :name: Argon
88
+ :symbol: Ar
89
+ :atomic_num: 18
90
+ :atomic_amount: 39.948
91
+ 19:
92
+ :name: Postassium
93
+ :symbol: K
94
+ :atomic_num: 19
95
+ :atomic_amount: 39.0983
96
+ 20:
97
+ :name: Calcium
98
+ :symbol: Ca
99
+ :atomic_num: 20
100
+ :atomic_amount: 40.078
101
+ 21:
102
+ :name: Scandium
103
+ :symbol: Sc
104
+ :atomic_num: 21
105
+ :atomic_amount: 44.9559
106
+ 22:
107
+ :name: Titanium
108
+ :symbol: Ti
109
+ :atomic_num: 22
110
+ :atomic_amount: 47.867
111
+ 23:
112
+ :name: Vanadium
113
+ :symbol: V
114
+ :atomic_num: 23
115
+ :atomic_amount: 50.9415
116
+ 24:
117
+ :name: Chromium
118
+ :symbol: Cr
119
+ :atomic_num: 24
120
+ :atomic_amount: 51.9961
121
+ 25:
122
+ :name: Manganese
123
+ :symbol: Mn
124
+ :atomic_num: 25
125
+ :atomic_amount: 54.938
126
+ 26:
127
+ :name: Iron
128
+ :symbol: Fe
129
+ :atomic_num: 26
130
+ :atomic_amount: 55.845
131
+ 27:
132
+ :name: Cobalt
133
+ :symbol: Co
134
+ :atomic_num: 27
135
+ :atomic_amount: 58.9332
136
+ 28:
137
+ :name: Nickel
138
+ :symbol: Ni
139
+ :atomic_num: 28
140
+ :atomic_amount: 58.6934
141
+ 29:
142
+ :name: Copper
143
+ :symbol: Cu
144
+ :atomic_num: 29
145
+ :atomic_amount: 63.546
146
+ 30:
147
+ :name: Zinc
148
+ :symbol: Zn
149
+ :atomic_num: 30
150
+ :atomic_amount: 65.38
151
+ 31:
152
+ :name: Gallium
153
+ :symbol: Ga
154
+ :atomic_num: 31
155
+ :atomic_amount: 69.723
156
+ 32:
157
+ :name: Germanium
158
+ :symbol: Ge
159
+ :atomic_num: 32
160
+ :atomic_amount: 69.723
161
+ 33:
162
+ :name: Arsenic
163
+ :symbol: As
164
+ :atomic_num: 33
165
+ :atomic_amount: 74.9216
166
+ 34:
167
+ :name: Selenium
168
+ :symbol: Se
169
+ :atomic_num: 34
170
+ :atomic_amount: 78.971
171
+ 35:
172
+ :name: Bromine
173
+ :symbol: Br
174
+ :atomic_num: 35
175
+ :atomic_amount: 79.904
176
+ 36:
177
+ :name: Krypton
178
+ :symbol: Kr
179
+ :atomic_num: 36
180
+ :atomic_amount: 83.798
181
+ 37:
182
+ :name: Rubidium
183
+ :symbol: Rb
184
+ :atomic_num: 37
185
+ :atomic_amount: 85.4678
186
+ 38:
187
+ :name: Strontium
188
+ :symbol: Sr
189
+ :atomic_num: 38
190
+ :atomic_amount: 87.62
191
+ 39:
192
+ :name: Yttrium
193
+ :symbol: Y
194
+ :atomic_num: 39
195
+ :atomic_amount: 88.9058
196
+ 40:
197
+ :name: Zirconium
198
+ :symbol: Zr
199
+ :atomic_num: 40
200
+ :atomic_amount: 91.224
201
+ 41:
202
+ :name: Niobium
203
+ :symbol: Nb
204
+ :atomic_num: 41
205
+ :atomic_amount: 92.9064
206
+ 42:
207
+ :name: Molybdenum
208
+ :symbol: Mo
209
+ :atomic_num: 42
210
+ :atomic_amount: 95.95
211
+ 43:
212
+ :name: Technetium
213
+ :symbol: Tc
214
+ :atomic_num: 43
215
+ :atomic_amount: 99
216
+ 44:
217
+ :name: Ruthenium
218
+ :symbol: Ru
219
+ :atomic_num: 44
220
+ :atomic_amount: 101.07
221
+ 45:
222
+ :name: Rhodium
223
+ :symbol: Rh
224
+ :atomic_num: 45
225
+ :atomic_amount: 102.906
226
+ 46:
227
+ :name: Palladium
228
+ :symbol: Pd
229
+ :atomic_num: 46
230
+ :atomic_amount: 106.42
231
+ 47:
232
+ :name: Silver
233
+ :symbol: Ag
234
+ :atomic_num: 47
235
+ :atomic_amount: 107.868
236
+ 48:
237
+ :name: Cadmium
238
+ :symbol: Cd
239
+ :atomic_num: 48
240
+ :atomic_amount: 112.414
241
+ 49:
242
+ :name: Indium
243
+ :symbol: In
244
+ :atomic_num: 49
245
+ :atomic_amount: 114.818
246
+ 50:
247
+ :name: Tin
248
+ :symbol: Sn
249
+ :atomic_num: 50
250
+ :atomic_amount: 118.710
251
+ 51:
252
+ :name: Antimony
253
+ :symbol: Sb
254
+ :atomic_num: 51
255
+ :atomic_amount: 121.760
256
+ 52:
257
+ :name: Tellurium
258
+ :symbol: Te
259
+ :atomic_num: 52
260
+ :atomic_amount: 127.60
261
+ 53:
262
+ :name: Iodine
263
+ :symbol: I
264
+ :atomic_num: 53
265
+ :atomic_amount: 126.904
266
+ 54:
267
+ :name: Xenon
268
+ :symbol: Xe
269
+ :atomic_num: 54
270
+ :atomic_amount: 131.293
271
+ 55:
272
+ :name: Cesium
273
+ :symbol: Cs
274
+ :atomic_num: 55
275
+ :atomic_amount: 132.905
276
+ 56:
277
+ :name: Barium
278
+ :symbol: Ba
279
+ :atomic_num: 56
280
+ :atomic_amount: 137.327
281
+ 57:
282
+ :name: Lanthanum
283
+ :symbol: La
284
+ :atomic_num: 57
285
+ :atomic_amount: 138.905
286
+ 58:
287
+ :name: Cerium
288
+ :symbol: Ce
289
+ :atomic_num: 58
290
+ :atomic_amount: 140.116
291
+ 59:
292
+ :name: Praseodymium
293
+ :symbol: Pr
294
+ :atomic_num: 59
295
+ :atomic_amount: 140.908
296
+ 60:
297
+ :name: Neodymium
298
+ :symbol: Nd
299
+ :atomic_num: 60
300
+ :atomic_amount: 144.242
301
+ 61:
302
+ :name: Promethium
303
+ :symbol: Pm
304
+ :atomic_num: 61
305
+ :atomic_amount: 145
306
+ 62:
307
+ :name: Samarium
308
+ :symbol: Sm
309
+ :atomic_num: 62
310
+ :atomic_amount: 150.36
311
+ 63:
312
+ :name: Europium
313
+ :symbol: Eu
314
+ :atomic_num: 63
315
+ :atomic_amount: 151.25
316
+ 64:
317
+ :name: Gadolinium
318
+ :symbol: Gd
319
+ :atomic_num: 64
320
+ :atomic_amount: 157.25
321
+ 65:
322
+ :name: Terbium
323
+ :symbol: Tb
324
+ :atomic_num: 65
325
+ :atomic_amount: 158.925
326
+ 66:
327
+ :name: Dysprosium
328
+ :symbol: Dy
329
+ :atomic_num: 65
330
+ :atomic_amount: 162.500
331
+ 67:
332
+ :name: Holmium
333
+ :symbol: Ho
334
+ :atomic_num: 67
335
+ :atomic_amount: 164.930
336
+ 68:
337
+ :name: Erbium
338
+ :symbol: Er
339
+ :atomic_num: 68
340
+ :atomic_amount: 167.259
341
+ 69:
342
+ :name: Thulium
343
+ :symbol: Tm
344
+ :atomic_num: 69
345
+ :atomic_amount: 168.934
346
+ 70:
347
+ :name: Ytterbium
348
+ :symbol: Yb
349
+ :atomic_num: 70
350
+ :atomic_amount: 173.045
351
+ 71:
352
+ :name: Lutetium
353
+ :symbol: Lu
354
+ :atomic_num: 71
355
+ :atomic_amount: 174.967
356
+ 72:
357
+ :name: Hafnium
358
+ :symbol: Fh
359
+ :atomic_num: 72
360
+ :atomic_amount: 178l49
361
+ 73:
362
+ :name: Tantalum
363
+ :symbol: Ta
364
+ :atomic_num: 73
365
+ :atomic_amount: 180.948
366
+ 74:
367
+ :name: Tungsten
368
+ :symbol: W
369
+ :atomic_num: 74
370
+ :atomic_amount: 183.84
371
+ 75:
372
+ :name: Rhenium
373
+ :symbol: Re
374
+ :atomic_num: 75
375
+ :atomic_amount: 186.207
376
+ 76:
377
+ :name: Osmium
378
+ :symbol: Os
379
+ :atomic_num: 76
380
+ :atomic_amount: 190.23
381
+ 77:
382
+ :name: Iridium
383
+ :symbol: Ir
384
+ :atomic_num: 77
385
+ :atomic_amount: 192.217
386
+ 78:
387
+ :name: Platinum
388
+ :symbol: Pt
389
+ :atomic_num: 78
390
+ :atomic_amount: 195.084
391
+ 79:
392
+ :name: Gold
393
+ :symbol: Au
394
+ :atomic_num: 79
395
+ :atomic_amount: 196.967
396
+ 80:
397
+ :name: Mercury
398
+ :symbol: Hg
399
+ :atomic_num: 80
400
+ :atomic_amount: 200.592
401
+ 81:
402
+ :name: Thallium
403
+ :symbol: Tl
404
+ :atomic_num: 81
405
+ :atomic_amount: 204.384
406
+ 82:
407
+ :name: Lead
408
+ :symbol: Pb
409
+ :atomic_num: 82
410
+ :atomic_amount: 207.2
411
+ 83:
412
+ :name: Bismuth
413
+ :symbol: Bi
414
+ :atomic_num: 83
415
+ :atomic_amount: 208.980
416
+ 84:
417
+ :name: Polonium
418
+ :symbol: Po
419
+ :atomic_num: 84
420
+ :atomic_amount: 210
421
+ 85:
422
+ :name: Astatine
423
+ :symbol: At
424
+ :atomic_num: 85
425
+ :atomic_amount: 210
426
+ 86:
427
+ :name: Radon
428
+ :symbol: Rn
429
+ :atomic_num: 86
430
+ :atomic_amount: 222
431
+ 87:
432
+ :name: Francium
433
+ :symbol: Fr
434
+ :atomic_num: 87
435
+ :atomic_amount: 223
436
+ 88:
437
+ :name: Radium
438
+ :symbol: Ra
439
+ :atomic_num: 88
440
+ :atomic_amount: 226
441
+ 89:
442
+ :name: Actinium
443
+ :symbol: Ac
444
+ :atomic_num: 89
445
+ :atomic_amount: 227
446
+ 90:
447
+ :name: Thorium
448
+ :symbol: Th
449
+ :atomic_num: 90
450
+ :atomic_amount: 232.038
451
+ 91:
452
+ :name: Protactinium
453
+ :symbol: Pa
454
+ :atomic_num: 91
455
+ :atomic_amount: 231.036
456
+ 92:
457
+ :name: Uranium
458
+ :symbol: U
459
+ :atomic_num: 92
460
+ :atomic_amount: 238.029
461
+ 93:
462
+ :name: Neptunium
463
+ :symbol: Np
464
+ :atomic_num: 93
465
+ :atomic_amount: 238
466
+ 94:
467
+ :name: Plutonium
468
+ :symbol: Pu
469
+ :atomic_num: 94
470
+ :atomic_amount: 239
471
+ 95:
472
+ :name: Americium
473
+ :symbol: Am
474
+ :atomic_num: 95
475
+ :atomic_amount: 243
476
+ 96:
477
+ :name: Curium
478
+ :symbol: Cm
479
+ :atomic_num: 96
480
+ :atomic_amount: 247
481
+ 97:
482
+ :name: Berkelium
483
+ :symbol: Bk
484
+ :atomic_num: 97
485
+ :atomic_amount: 247
486
+ 98:
487
+ :name: Califormium
488
+ :symbol: Cf
489
+ :atomic_num: 252
490
+ :atomic_amount: 252
491
+ 99:
492
+ :name: Einsteinium
493
+ :symbol: Es
494
+ :atomic_num: 99
495
+ :atomic_amount: 252
496
+ 100:
497
+ :name: Fermium
498
+ :symbol: Fm
499
+ :atomic_num: 100
500
+ :atomic_amount: 257
501
+ 101:
502
+ :name: Mendelevium
503
+ :symbol: Md
504
+ :atomic_num: 101
505
+ :atomic_amount: 258
506
+ 102:
507
+ :name: Nobelium
508
+ :symbol: No
509
+ :atomic_num: 102
510
+ :atomic_amount: 259
511
+ 103:
512
+ :name: Lawrencium
513
+ :symbol: Lr
514
+ :atomic_num: 103
515
+ :atomic_amount: 262
516
+ 104:
517
+ :name: Rutherfordium
518
+ :symbol: Rf
519
+ :atomic_num: 104
520
+ :atomic_amount: 267
521
+ 105:
522
+ :name: Dubnium
523
+ :symbol: Db
524
+ :atomic_num: 105
525
+ :atomic_amount: 268
526
+ 106:
527
+ :name: Seaborgium
528
+ :symbol: Sg
529
+ :atomic_num: 106
530
+ :atomic_amount: 271
531
+ 107:
532
+ :name: Bohrium
533
+ :symbol: Bh
534
+ :atomic_num: 107
535
+ :atomic_amount: 272
536
+ 108:
537
+ :name: Hassium
538
+ :symbol: Hs
539
+ :atomic_num: 108
540
+ :atomic_amount: 277
541
+ 109:
542
+ :name: Meitnerium
543
+ :symbol: Mt
544
+ :atomic_num: 109
545
+ :atomic_amount: 276
546
+ 110:
547
+ :name: Darmstadtium
548
+ :symbol: Ds
549
+ :atomic_num: 110
550
+ :atomic_amount: 281
551
+ 111:
552
+ :name: Roentgenium
553
+ :symbol: Rg
554
+ :atomic_num: 111
555
+ :atomic_amount: 280
556
+ 112:
557
+ :name: Copernicium
558
+ :symbol: Cn
559
+ :atomic_num: 112
560
+ :atomic_amount: 285
561
+ 113:
562
+ :name: Nihonium
563
+ :symbol: Nh
564
+ :atomic_num: 113
565
+ :atomic_amount: 278
566
+ 114:
567
+ :name: Flerovium
568
+ :symbol: Fl
569
+ :atomic_num: 114
570
+ :atomic_amount: 289
571
+ 115:
572
+ :name: Moscovium
573
+ :symbol: Mc
574
+ :atomic_num: 115
575
+ :atomic_amount: 289
576
+ 116:
577
+ :name: Livermorium
578
+ :symbol: Lv
579
+ :atomic_num: 116
580
+ :atomic_amount: 293
581
+ 117:
582
+ :name: Tennessine
583
+ :symbol: Ts
584
+ :atomic_num: 117
585
+ :atomic_amount: 293
586
+ 118:
587
+ :name: Oganesson
588
+ :symbol: Og
589
+ :atomic_num: 118
590
+ :atomic_amount: 294
@@ -0,0 +1,51 @@
1
+ require 'yaml'
2
+ module ChemicalElements
3
+ class PeriodicTable
4
+ CHMICAL_FILE_PATH = '../data/chemical_elements.yml'.freeze
5
+
6
+ attr_accessor :name, :symbol, :atomic_num, :atomic_amount
7
+
8
+ def self.data
9
+ filepath = File.join(File.dirname(__FILE__), CHMICAL_FILE_PATH)
10
+ YAML.load_file(filepath)
11
+ end
12
+
13
+ def self.build(chemical_element)
14
+ chemical = new
15
+
16
+ chemical.name = chemical_element[:name]
17
+ chemical.symbol = chemical_element[:symbol]
18
+ chemical.atomic_num = chemical_element[:atomic_num]
19
+ chemical.atomic_amount = chemical_element[:atomic_amount]
20
+
21
+ chemical
22
+ end
23
+
24
+ def self.all
25
+ data.values.map { |value| build(value) }
26
+ end
27
+
28
+ def self.find(string)
29
+ return if string.nil?
30
+
31
+ chemical_element = find_chemcial_elements(:symbol, string)
32
+ build(chemical_element)
33
+ end
34
+
35
+ def self.find_by(args)
36
+ return if args.nil?
37
+
38
+ chemical_element = find_chemcial_elements(args.keys[0], args.values[0])
39
+ build(chemical_element)
40
+ end
41
+
42
+ def self.find_chemcial_elements(key, value)
43
+ case key
44
+ when :name, :symbol
45
+ data.values.map { |val| return val if val[key].casecmp(value).zero? }
46
+ when :atomic_num, :atomic_amount
47
+ data.values.map { |val| return val if val[key] == value }
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ module ChemicalElements
2
+ VERSION = '0.1.0'.freeze
3
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chemical_elements
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - hatsu38
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-09-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: Provide chemical element list data based on the periodic table.
56
+ email:
57
+ - hajiwata0308@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".circleci/config.yml"
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".rubocop.yml"
66
+ - ".travis.yml"
67
+ - CHANGELOG.md
68
+ - CODE_OF_CONDUCT.md
69
+ - Gemfile
70
+ - Gemfile.lock
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - bin/console
75
+ - bin/setup
76
+ - chemical_elements.gemspec
77
+ - data/chemical_elements.yml
78
+ - lib/chemical_elements.rb
79
+ - lib/chemical_elements/version.rb
80
+ homepage: https://github.com/hatsu38/chemical_elements
81
+ licenses:
82
+ - MIT
83
+ metadata:
84
+ homepage_uri: https://github.com/hatsu38/chemical_elements
85
+ source_code_uri: https://github.com/hatsu38/chemical_elements
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubygems_version: 3.0.3
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Provide chemical element list data based on the periodic table.
105
+ test_files: []