info_unit 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/info_unit.gemspec +1 -1
- data/lib/info_unit.rb +5 -1
- data/spec/info_unit_spec.rb +28 -8
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/info_unit.gemspec
CHANGED
data/lib/info_unit.rb
CHANGED
data/spec/info_unit_spec.rb
CHANGED
@@ -10,10 +10,15 @@ describe "InfoUnit" do
|
|
10
10
|
InfoUnit.new('100KB'),
|
11
11
|
InfoUnit.new('100 KB'),
|
12
12
|
].each do |x|
|
13
|
+
bytes = 100 * 1024
|
13
14
|
x.number.should == 100
|
14
15
|
x.unit.should == 'KB'
|
15
|
-
x.bytes.should ==
|
16
|
-
x.to_hash.should == {
|
16
|
+
x.bytes.should == bytes
|
17
|
+
x.to_hash.should == {
|
18
|
+
:number => 100,
|
19
|
+
:unit => 'KB',
|
20
|
+
:bytes => bytes,
|
21
|
+
}
|
17
22
|
end
|
18
23
|
end
|
19
24
|
|
@@ -23,10 +28,15 @@ describe "InfoUnit" do
|
|
23
28
|
InfoUnit.new('27MB'),
|
24
29
|
InfoUnit.new('27 MB'),
|
25
30
|
].each do |x|
|
31
|
+
bytes = 27 * 1048576
|
26
32
|
x.number.should == 27
|
27
33
|
x.unit.should == 'MB'
|
28
|
-
x.bytes.should ==
|
29
|
-
x.to_hash.should == {
|
34
|
+
x.bytes.should == bytes
|
35
|
+
x.to_hash.should == {
|
36
|
+
:number => 27,
|
37
|
+
:unit => 'MB',
|
38
|
+
:bytes => bytes,
|
39
|
+
}
|
30
40
|
end
|
31
41
|
end
|
32
42
|
|
@@ -36,10 +46,15 @@ describe "InfoUnit" do
|
|
36
46
|
InfoUnit.new('2.3MB'),
|
37
47
|
InfoUnit.new('2.3 MB'),
|
38
48
|
].each do |x|
|
49
|
+
bytes = 2.3 * 1048576
|
39
50
|
x.number.should == 2.3
|
40
51
|
x.unit.should == 'MB'
|
41
|
-
x.bytes.should ==
|
42
|
-
x.to_hash.should == {
|
52
|
+
x.bytes.should == bytes
|
53
|
+
x.to_hash.should == {
|
54
|
+
:number => 2.3,
|
55
|
+
:unit => 'MB',
|
56
|
+
:bytes => bytes,
|
57
|
+
}
|
43
58
|
end
|
44
59
|
end
|
45
60
|
|
@@ -49,10 +64,15 @@ describe "InfoUnit" do
|
|
49
64
|
InfoUnit.new('1.01KB'),
|
50
65
|
InfoUnit.new('1.01 KB'),
|
51
66
|
].each do |x|
|
67
|
+
bytes = 1.01 * 1024
|
52
68
|
x.number.should == 1.01
|
53
69
|
x.unit.should == 'KB'
|
54
|
-
x.bytes.should ==
|
55
|
-
x.to_hash.should == {
|
70
|
+
x.bytes.should == bytes
|
71
|
+
x.to_hash.should == {
|
72
|
+
:number => 1.01,
|
73
|
+
:unit => 'KB',
|
74
|
+
:bytes => bytes,
|
75
|
+
}
|
56
76
|
end
|
57
77
|
end
|
58
78
|
|