Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Defined in:
- lib/redis/dump.rb
Instance Method Summary collapse
-
#to_bytes ⇒ Object
TODO: Use 1024?.
- #to_ms ⇒ Object
Instance Method Details
#to_bytes ⇒ Object
TODO: Use 1024?
307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/redis/dump.rb', line 307 def to_bytes args = case self.abs.to_i when (1000)..(1000**2) '%3.2f%s' % [(self / 1000.to_f).to_s, 'KB'] when (1000**2)..(1000**3) '%3.2f%s' % [(self / (1000**2).to_f).to_s, 'MB'] when (1000**3)..(1000**4) '%3.2f%s' % [(self / (1000**3).to_f).to_s, 'GB'] when (1000**4)..(1000**6) '%3.2f%s' % [(self / (1000**4).to_f).to_s, 'TB'] else [self, 'B'].join end end |
#to_ms ⇒ Object
302 303 304 |
# File 'lib/redis/dump.rb', line 302 def to_ms (self*1000).to_i end |