valuevaluevalue 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 34d6610fa48f79dc1c88b59a7f186d6c565a083f
4
+ data.tar.gz: 5c58893f008f21f7f6a7fda02fdc0953b7769dae
5
+ SHA512:
6
+ metadata.gz: 53e5cfc2a54e2e4d2b1b4c24d3f5b3f240ae046745d240e21777665b18b96067d114a96e2ae2ce92cf0e8bcd2d7e05656c58ab59c4a76860c3f239808838c9fe
7
+ data.tar.gz: 0bb90aee6b6816c048e848de2d429e940b6d4bb859a5ab1440a2a935020f274874036e9be6d6aa9ac91a41df705dfe68abc31c0efd59b99ddf0db5e01a219164
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /.idea/
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ - 2.3.0
6
+ - 2.2.0
7
+ - 2.1.0
8
+ - 2.0.0
9
+ - 1.9.3
10
+ - jruby
11
+
12
+ before_install: gem install bundler -v 1.14.6
@@ -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 esadoff@ardiangroup.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,10 @@
1
+ # coding: utf-8
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ group :development do
6
+ gem 'bundler', '~> 1.14'
7
+ gem 'rake', '~> 10'
8
+ gem 'rspec', '~> 3.0'
9
+ gem 'simplecov', '~> 0.14'
10
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Eli Sadoff
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,35 @@
1
+ # Valuevaluevalue
2
+
3
+ This gem is to be used for value conversion.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'valuevaluevalue'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install valuevaluevalue
20
+
21
+ ## Development
22
+
23
+ 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.
24
+
25
+ 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).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/snood1205/valuevaluevalue. 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.
30
+
31
+
32
+ ## License
33
+
34
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
35
+
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # coding: utf-8
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,8 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require 'bundler/setup'
5
+ require 'valuevaluevalue'
6
+
7
+ require 'irb'
8
+ 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,60 @@
1
+ # coding: utf-8
2
+
3
+ module Valuevaluevalue
4
+ class Mass
5
+ attr_accessor :value, :unit
6
+
7
+ UNITS = [
8
+ MassUnit.new('Atomic Mass Unit', 'amu', 1.6605402e-27),
9
+ MassUnit.new('Carat', 'ct', 0.0002),
10
+ MassUnit.new('Cental', 'cwt', 45.359237),
11
+ MassUnit.new('Centigram', 'cg', 0.00001),
12
+ MassUnit.new('Decagram', 'dkg', 0.01),
13
+ MassUnit.new('Dram', 'dr', 0.001771845195312),
14
+ MassUnit.new('Grain', 'gr', 0.00006479891),
15
+ MassUnit.new('Gram', 'g', 0.001),
16
+ MassUnit.new('Hundredweight', 'hwt', 50.80234544),
17
+ MassUnit.new('Kilogram', 'kg', 1),
18
+ MassUnit.new('Long Ton', 'lton', 1016.0469088),
19
+ MassUnit.new('Microgram', 'mcg', 1E-9),
20
+ MassUnit.new('Milligram', 'mg', 0.000001),
21
+ MassUnit.new('Ounce', 'oz', 0.028349523125),
22
+ MassUnit.new('Pennyweight', 'dwt', 0.00155517384),
23
+ MassUnit.new('Pound', 'lbs', 0.45359237),
24
+ MassUnit.new('Quarter', 'qt', 12.70058636),
25
+ MassUnit.new('Short Ton', 'ton', 907.18474),
26
+ MassUnit.new('Stone', 'st', 6.35029318),
27
+ MassUnit.new('Tonne', 't', 1000),
28
+ MassUnit.new('Troy Ounce', 'troz', 0.0311034768)
29
+ ].freeze
30
+
31
+ def initialize(value, unit)
32
+ unit_exists?(unit)
33
+ @value = value
34
+ @unit = unit
35
+ end
36
+
37
+ def convert_to(unit)
38
+ unit_exists?(unit)
39
+ convert_to_kg / find_unit(unit).mass_in_kg
40
+ end
41
+
42
+ private
43
+
44
+ def unit_exists?(unit)
45
+ UNITS.include?(unit) ||
46
+ UNITS.map(&:name).include?(unit.to_s) ||
47
+ UNITS.map(&:abbreviation).include?(unit.to_s)
48
+ end
49
+
50
+ def find_unit(unit)
51
+ raise 'Unit does not exist' unless unit_exists?(unit)
52
+ unit = unit.to_s
53
+ UNITS.select { |u| u.name == unit || u.abbreviation == unit }.first
54
+ end
55
+
56
+ def convert_to_kg
57
+ value * unit.mass_in_kg
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+
3
+ module Valuevaluevalue
4
+ class Unit
5
+ attr_accessor :name, :abbreviation
6
+
7
+ def initialize(name, abbreviation)
8
+ @name = name
9
+ @abbreviation = abbreviation
10
+ end
11
+ end
12
+
13
+ class MassUnit < Unit
14
+ attr_accessor :mass_in_kg
15
+
16
+ def initialize(name, abbreviation, mass_in_kg)
17
+ super(name, abbreviation)
18
+ @mass_in_kg = mass_in_kg
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,5 @@
1
+ # coding: utf-8
2
+
3
+ module Valuevaluevalue
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,8 @@
1
+ # coding: utf-8
2
+
3
+ require 'valuevaluevalue/version'
4
+ require 'valuevaluevalue/unit'
5
+ require 'valuevaluevalue/mass'
6
+
7
+ module Valuevaluevalue
8
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'valuevaluevalue/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'valuevaluevalue'
8
+ spec.version = Valuevaluevalue::VERSION
9
+ spec.author = 'Eli Sadoff'
10
+ spec.email = 'esadoff@ardiangroup.com'
11
+
12
+ spec.summary = 'A value converting gem.'
13
+ spec.homepage = 'https://github.com/snood1205/valuevaluevalue'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = %w[lib]
23
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: valuevaluevalue
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Eli Sadoff
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-05-06 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: esadoff@ardiangroup.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".gitignore"
20
+ - ".rspec"
21
+ - ".travis.yml"
22
+ - CODE_OF_CONDUCT.md
23
+ - Gemfile
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - bin/console
28
+ - bin/setup
29
+ - lib/valuevaluevalue.rb
30
+ - lib/valuevaluevalue/mass.rb
31
+ - lib/valuevaluevalue/unit.rb
32
+ - lib/valuevaluevalue/version.rb
33
+ - valuevaluevalue.gemspec
34
+ homepage: https://github.com/snood1205/valuevaluevalue
35
+ licenses:
36
+ - MIT
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 2.6.11
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: A value converting gem.
58
+ test_files: []