unit_conversion 1.0.0 → 1.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68887ea137015923e97e347524f28adf500c680d
4
- data.tar.gz: 7695075cc307ab4434b4c2a7f5c3ac23d0974ca3
3
+ metadata.gz: 7d1b1cb84ec137f330433ede0d8809940300ee2c
4
+ data.tar.gz: ec3f65bb4560bff65baecb2f2544d63b2bdb050f
5
5
  SHA512:
6
- metadata.gz: dab48b97c409bf00ded4ce5fbf9c02132e8abf03669cc32abc07a3d49c6d580f3c28d9ed95c52ad4d1520b7947cea188e87af9ce561e33e49ff16befe1449f58
7
- data.tar.gz: fb106eb367d76f3a8c0c1cb93f38d4f9dd60a691b82a1a603341237c66b66ffa93845839a9f0abf52d5d5de4fa27917d0f8b2536875cc624fafcd7a2cae3d86d
6
+ metadata.gz: ea517e96d9e4a2ebeac0dcc90450cb9511172a4c9ff2b7c83e45dd9e51c50f72db75cb3f415f9cd8418f8ed5037e2d633efaeeb5669b3ef913723cb215f25843
7
+ data.tar.gz: 04287ec871d81369fb7700de63dbdd52d6bfb555026720cfc550d630de2711b0050390132793a25b71eb48e76b33078653621d8d45245c33c215106111ff9c8d
data/README.md CHANGED
@@ -1,10 +1,9 @@
1
1
  # UnitConversion
2
2
 
3
- An updated unit conversion plugin for rails.
3
+ An up-to-date, easy to use unit conversion gem.
4
4
 
5
5
  ## Dependencies
6
6
  Ruby 2.x
7
- Rails 4.x
8
7
 
9
8
  ## Installation
10
9
 
@@ -24,6 +23,7 @@ Or install it yourself as:
24
23
 
25
24
  ## Usage
26
25
  If you want to convert from Celcius to Kelvin:
26
+
27
27
  temperate = UnitConversion.new(0, 'celcius')
28
28
  temperature.to_kelvin
29
29
 
@@ -52,9 +52,27 @@ Distance:
52
52
  - Foot
53
53
  - Yard
54
54
 
55
+ Weight:
56
+ - Gram
57
+ - Ounce
58
+ - Pound
59
+ - Short Ton (US ton)
60
+ - Long Ton (British ton)
61
+
55
62
  ## Development
56
63
 
57
- We'll be adding more conversions focusing on temperature conversions first. Feel free to email me suggestions if you want a certain conversion that isn't included in this gem.
64
+ ** Next Version: **
65
+ - more metric conversions for all measurements (ex: centi prefixes)
66
+
67
+ ** Future measurements for conversion: **
68
+ - speed conversions
69
+ - volume
70
+ - area
71
+ - time
72
+ - frequency
73
+ - data transfer rate
74
+ - digital storage
75
+ - energy
58
76
 
59
77
  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.
60
78
 
@@ -1,11 +1,13 @@
1
1
  require_relative "unit_conversion/version"
2
2
  require_relative "unit_conversion/distance_conversion"
3
3
  require_relative "unit_conversion/temperature_conversion"
4
+ require_relative "unit_conversion/weight_conversion"
4
5
 
5
6
  class UnitConversion
6
7
  attr_accessor :measurement
7
8
  include DistanceConversion
8
9
  include TemperatureConversion
10
+ include WeightConversion
9
11
 
10
12
  def initialize(measurement, unit)
11
13
  @measurement = measurement
@@ -1,3 +1,3 @@
1
1
  class UnitConversion
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -0,0 +1,55 @@
1
+ module WeightConversion
2
+ # Proxy = Kilogram
3
+ def to_kilogram
4
+ case @unit
5
+ when 'pound'
6
+ @measurement *= 0.45359
7
+ when 'ounce'
8
+ @measurement *= 0.02835
9
+ when 'short_ton'
10
+ @measurement *= 907.18464
11
+ when 'long_ton'
12
+ @measurement *= 1016.04691
13
+ end
14
+ end
15
+
16
+ def to_long_ton
17
+ if @unit == 'kilogram'
18
+ @measurement *= 0.000984207
19
+ else
20
+ self.to_kilogram
21
+ @unit = 'kilogram'
22
+ self.to_long_ton
23
+ end
24
+ end
25
+
26
+ def to_short_ton
27
+ if @unit == 'kilogram'
28
+ @measurement *= 0.00110231
29
+ else
30
+ self.to_kilogram
31
+ @unit = 'kilogram'
32
+ self.to_short_ton
33
+ end
34
+ end
35
+
36
+ def to_pound
37
+ if @unit == 'kilogram'
38
+ @measurement *= 2.2046226218
39
+ else
40
+ self.to_kilogram
41
+ @unit = 'kilogram'
42
+ self.to_pound
43
+ end
44
+ end
45
+
46
+ def to_ounce
47
+ if @unit == 'kilogram'
48
+ @measurement *= 35.27396195
49
+ else
50
+ self.to_kilogram
51
+ @unit = 'kilogram'
52
+ self.to_ounce
53
+ end
54
+ end
55
+ 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: 1.0.0
4
+ version: 1.0.1
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-06 00:00:00.000000000 Z
11
+ date: 2015-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,6 +73,7 @@ files:
73
73
  - lib/unit_conversion/distance_conversion.rb
74
74
  - lib/unit_conversion/temperature_conversion.rb
75
75
  - lib/unit_conversion/version.rb
76
+ - lib/unit_conversion/weight_conversion.rb
76
77
  - unit_conversion.gemspec
77
78
  homepage: https://github.com/eternal44/unit_conversion
78
79
  licenses: