unit_conversion 0.0.1 → 0.0.2
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 +4 -4
- data/CODE_OF_CONDUCT.md +2 -0
- data/README.md +22 -0
- data/lib/unit_conversion/version.rb +1 -1
- data/lib/unit_conversion.rb +42 -6
- metadata +2 -3
- data/lib/unit_conversion/temperature_conversion.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c936d89fcb397247f45ddaf56727bfda66437cf7
|
4
|
+
data.tar.gz: 739ce135b515c30f5447c1aefe6dc71e35a44558
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9aa673263a4144cc1be37c48c34f67eaed9f37a5c2398f3b1fd31d8fb23a792c684bfa9d8b1dae513891fb0e5d4b1b07b47a9f8bf61b528e7bba6a392aea352
|
7
|
+
data.tar.gz: d6735e14544d01510ac6d368d651419798d9e55356038cce0365f4615d8c34f11b7a57628e5f1d8b60ba0f6a1bd292bbacbb9216fe2e87d096d444b2edcb1805
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Contributor Code of Conduct
|
2
2
|
|
3
|
+
--NOTE adopted from Bundler and modified--
|
4
|
+
|
3
5
|
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
6
|
|
5
7
|
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
data/README.md
CHANGED
@@ -23,14 +23,36 @@ Or install it yourself as:
|
|
23
23
|
$ gem install unit_conversion
|
24
24
|
|
25
25
|
## Usage
|
26
|
+
Always refer to unit conversion methods without an 's':
|
27
|
+
|
28
|
+
Wrong way: inches_to_feet
|
29
|
+
Right way: inch_to_feet
|
30
|
+
|
31
|
+
Instructions:
|
26
32
|
|
27
33
|
temperate = UnitConversion.new(0)
|
28
34
|
temperature.celcius_to_kelvin
|
29
35
|
|
30
36
|
=> 273.15
|
31
37
|
|
38
|
+
## Units available for conversion
|
39
|
+
|
40
|
+
Temperature:
|
41
|
+
- Fahrenheit
|
42
|
+
- Celcius
|
43
|
+
- Kelvin
|
44
|
+
- Rankine
|
45
|
+
|
46
|
+
Distance:
|
47
|
+
- Metric
|
48
|
+
- Imperial
|
49
|
+
|
32
50
|
## Development
|
33
51
|
|
52
|
+
I'll be adding more conversions along with a small group I'm working
|
53
|
+
with. Feel free to watch this repo to keep up with what new conversions
|
54
|
+
we add.
|
55
|
+
|
34
56
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
35
57
|
|
36
58
|
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).
|
data/lib/unit_conversion.rb
CHANGED
@@ -5,18 +5,22 @@ class UnitConversion
|
|
5
5
|
@measurement = measurement
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
###########################
|
9
|
+
# TEMPERATURE CONVERSIONS #
|
10
|
+
###########################
|
11
11
|
|
12
12
|
def celcius_to_kelvin
|
13
|
-
@measurement+ 273.15
|
13
|
+
@measurement + 273.15
|
14
14
|
end
|
15
15
|
|
16
16
|
def fahrenheit_to_kelvin
|
17
17
|
(@measurement + 459.67) * 5 / 9
|
18
18
|
end
|
19
19
|
|
20
|
+
def rankine_to_kelvin
|
21
|
+
@measurement / 1.8
|
22
|
+
end
|
23
|
+
|
20
24
|
def kelvin_to_celcius
|
21
25
|
@measurement - 273.15
|
22
26
|
end
|
@@ -29,7 +33,39 @@ class UnitConversion
|
|
29
33
|
@measurement * 1.8
|
30
34
|
end
|
31
35
|
|
32
|
-
|
33
|
-
|
36
|
+
########################
|
37
|
+
# DISTANCE CONVERSIONS #
|
38
|
+
########################
|
39
|
+
|
40
|
+
def feet_to_inch
|
41
|
+
@measurement / 12.0
|
42
|
+
end
|
43
|
+
|
44
|
+
def inch_to_feet
|
45
|
+
@measurement * 12.0
|
46
|
+
end
|
47
|
+
|
48
|
+
def feet_to_yard
|
49
|
+
@measurement * 3.0
|
50
|
+
end
|
51
|
+
|
52
|
+
def yard_to_feet
|
53
|
+
@measurement / 3.0
|
54
|
+
end
|
55
|
+
|
56
|
+
def feet_to_mile
|
57
|
+
@measurement / 5280.0
|
58
|
+
end
|
59
|
+
|
60
|
+
def mile_to_feet
|
61
|
+
@measurement * 5280.0
|
62
|
+
end
|
63
|
+
|
64
|
+
def feet_to_meter
|
65
|
+
@measurement * 0.3048
|
66
|
+
end
|
67
|
+
|
68
|
+
def meter_to_feet
|
69
|
+
@measurement / 0.3048
|
34
70
|
end
|
35
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unit_conversion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Youn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,7 +70,6 @@ files:
|
|
70
70
|
- bin/console
|
71
71
|
- bin/setup
|
72
72
|
- lib/unit_conversion.rb
|
73
|
-
- lib/unit_conversion/temperature_conversion.rb
|
74
73
|
- lib/unit_conversion/version.rb
|
75
74
|
- unit_conversion.gemspec
|
76
75
|
homepage: https://github.com/eternal44/unit_conversion
|