filesize 0.0.4 → 0.1.0

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.
@@ -28,6 +28,11 @@ Filesize.from("12502343 B").to_s('GiB') # => "0.01 GiB"
28
28
  Filesize.from("12502343 B").pretty # => "11.92 MiB"
29
29
  ```
30
30
 
31
+ ### Comparing filesizes
32
+ ```ruby
33
+ Filesize.from("1 KB") <=> Filesize.from("1 MB") # => -1
34
+ ```
35
+
31
36
  ### Calculating with filesizes
32
37
  #### The file size on the left side sets the type
33
38
  ```ruby
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "filesize"
4
- s.version = "0.0.4"
4
+ s.version = "0.1.0"
5
5
 
6
6
  s.authors = ["Dominik Honnef"]
7
7
  s.date = %q{2009-07-26}
@@ -1,4 +1,6 @@
1
1
  class Filesize
2
+ include Comparable
3
+
2
4
  TYPE_PREFIXES = {
3
5
  # Unit prefixes used for SI file sizes.
4
6
  SI: %w{k M G T P E Z Y},
@@ -107,9 +109,8 @@ class Filesize
107
109
  end
108
110
  end
109
111
 
110
- # @return [Boolean]
111
- def ==(other)
112
- other.is_a?(self.class) && other.to_i == self.to_i
112
+ def <=>(other)
113
+ self.to_i <=> other.to_i
113
114
  end
114
115
 
115
116
  # @return [Array<self, other>]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filesize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: