flash_extensions 1.1.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84e33f32740d184881ab80b16d847d22e8effbeb
4
- data.tar.gz: 8ddffe7c316ce91abdbbc05451fee2c1e418dbb3
3
+ metadata.gz: 7455deab1af47127d78e60d860746fb77b069e3b
4
+ data.tar.gz: 2ffbf14a2ffd107255b51235b7a573e2009c52f5
5
5
  SHA512:
6
- metadata.gz: 342e1badd913766af4feea7a837f4e5a456c5359ff7573a2a50ab8291843e10b312d46982d28d63751f26a767efd0ae665b5e2aa62387c94e1c9aabaf1910e68
7
- data.tar.gz: bacebfbfc43a678f3b802669b8273e930673406b40f6c9d770f28cc45a1aeb1e0c8698dee18791d16695f36cf1ef9a94f22005489024f37399fac81d765dab2d
6
+ metadata.gz: 502975d2310a0ceb9c473c3fc90f3745ab1f8a1eb7e8a88a4a9deee85499ef01662fa593398d1a8517d908bfc262960617777f0409d935bf65197d0953e92835
7
+ data.tar.gz: fec59ac5db5027a705817e34eeb9120fbc19b840a452be91081758e68e20823fde2639723a7d0886673747a2fa29adefc29e85b22528cf8c5c45dc7220d9c932
data/README.md CHANGED
@@ -264,6 +264,14 @@ Use the `to_length` method to convert a length from one unit to another unit.
264
264
  2.to_length(:mi, :yd) #=> 3520 #IN
265
265
  ```
266
266
 
267
+ ####To Time Unit:####
268
+ Use the `to_time_unit` method to convert a time unit from one unit to another unit.
269
+
270
+ ```ruby
271
+ 120.to_time_unit #=> 2 #MIN
272
+ 2.to_time_unite(:day, :sec) #=> 172800 #SEC
273
+ ```
274
+
267
275
  ####To Temperature:####
268
276
  Use the `to_temperature` method to convert a temperature from one unit to another unit.
269
277
 
@@ -65,6 +65,12 @@ class Numeric
65
65
  end
66
66
  end
67
67
 
68
+ def to_time_unit(from=:sec, to=:min)
69
+ scalers = { sec: 1, min: 60 ** 1, hr: 60 ** 2, day: (60 ** 2) * 24, yr: (60 ** 2) * 24 * 365 }
70
+
71
+ self.to_f * scalers[from] / scalers[to]
72
+ end
73
+
68
74
  def to_weight(from=:g, to=:oz)
69
75
  imperical_scalers = {
70
76
  mg: 28349.523125, cg: 2834.9523125, g: 28.349523125, kg: 0.028349523125, mt: 0.000028349523125,
@@ -1,3 +1,3 @@
1
1
  module FlashExtensions
2
- VERSION = "1.1.0"
2
+ VERSION = "3.0.0"
3
3
  end
@@ -90,6 +90,29 @@ describe Numeric do
90
90
  end
91
91
  end
92
92
 
93
+ describe "#to_time" do
94
+ it "to be 2" do
95
+ expect(120.to_time_unit).to eq(2)
96
+ expect(120.to_time_unit(:sec, :min)).to eq(2)
97
+ end
98
+
99
+ it "to be 40" do
100
+ expect(2400.to_time_unit(:min, :hr)).to eq(40)
101
+ end
102
+
103
+ it "to be 3" do
104
+ expect(72.to_time_unit(:hr, :day)).to eq(3)
105
+ end
106
+
107
+ it "to be 5" do
108
+ expect(1825.to_time_unit(:day, :yr)).to eq(5)
109
+ end
110
+
111
+ it "to be 172800" do
112
+ expect(2.to_time_unit(:day, :sec)).to eq(172800)
113
+ end
114
+ end
115
+
93
116
  describe "#to_temperature" do
94
117
  it "to be 212" do
95
118
  expect(100.to_temperature).to eq(212)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flash_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-19 00:00:00.000000000 Z
11
+ date: 2014-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler