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 +4 -4
- data/README.md +8 -0
- data/lib/flash_extensions/extensions/numeric_extension.rb +6 -0
- data/lib/flash_extensions/version.rb +1 -1
- data/spec/lib/numeric_extension_spec.rb +23 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7455deab1af47127d78e60d860746fb77b069e3b
|
4
|
+
data.tar.gz: 2ffbf14a2ffd107255b51235b7a573e2009c52f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,
|
@@ -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:
|
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-
|
11
|
+
date: 2014-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|