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 CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/info_unit.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{info_unit}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David James"]
data/lib/info_unit.rb CHANGED
@@ -22,7 +22,11 @@ class InfoUnit
22
22
 
23
23
  def to_hash
24
24
  if @unit && @number
25
- { @unit => @number }
25
+ {
26
+ :number => @number,
27
+ :unit => @unit,
28
+ :bytes => bytes,
29
+ }
26
30
  else
27
31
  {}
28
32
  end
@@ -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 == 100 * 1024
16
- x.to_hash.should == { 'KB' => 100 }
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 == 27 * 1048576
29
- x.to_hash.should == { 'MB' => 27 }
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 == 2.3 * 1048576
42
- x.to_hash.should == { 'MB' => 2.3 }
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 == 1.01 * 1024
55
- x.to_hash.should == { 'KB' => 1.01 }
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: info_unit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David James