class Numeric

Public Instance Methods

_to_human_size(num, result = [], index = 0) click to toggle source
# File lib/evernote-exporter.rb, line 13
def _to_human_size(num, result = [], index = 0)
  human_units = ['B ', 'K ', 'M ', 'G ', 'T ', 'P ']

  if num >= 1024
    div, mod = num.divmod(1024)
    result.unshift([mod, human_units[index]])
    _to_human_size(div, result, index + 1)
  else
    result.unshift([num, human_units[index]])
  end
end
number_to_human_size(shortly = false) click to toggle source
# File lib/evernote-exporter.rb, line 7
def number_to_human_size(shortly = false)
  result = _to_human_size(self.to_i)
  result = result.first(2) if shortly
  result.join.strip
end