resources/memory/memory_size.rb
def to_s
    kilobytes = (@bytes / KILO).round
    if kilobytes == 0
      '0'
    elsif kilobytes % KILO == 0
      megabytes = kilobytes / KILO
      if megabytes % KILO == 0
        gigabytes = megabytes / KILO
        gigabytes.to_s + 'G'
      else
        megabytes.to_s + 'M'
      end
    else
      kilobytes.to_s + 'K'
    end
  end
# Returns a memory size as a string including a unit. If the memory size is not a whole number, it is rounded down.
# The returned unit is always kilobytes, megabytes, or gigabytes which are commonly used units.
#
# @return [String] the memory size as a string, e.g. "10K"
Returns a memory size as a string including a unit. If the memory size is not a whole number, it is rounded down.
The returned unit is always kilobytes, megabytes, or gigabytes which are commonly used units.
Returns a memory size as a string including a unit . If the memory size is not a whole number it is rounded down . The returned unit is always kilobytes megabytes or gigabytes which are commonly used units .
def to_s
    kilobytes = (@bytes / KILO).round
    if kilobytes == 0
      '0'
    elsif kilobytes % KILO == 0
      megabytes = kilobytes / KILO
      if megabytes % KILO == 0
        gigabytes = megabytes / KILO
        gigabytes.to_s + 'G'
      else
        megabytes.to_s + 'M'
      end
    else
      kilobytes.to_s + 'K'
    end
  end
def to_s kilobytes = ( @bytes / KILO ) . round if kilobytes == 0 '0' elsif kilobytes % KILO == 0 megabytes = kilobytes / KILO if megabytes % KILO == 0 gigabytes = megabytes / KILO gigabytes . to_s + 'G' else megabytes . to_s + 'M' end else kilobytes . to_s + 'K' end end
Returns a memory size as a string including a unit.
Returns a memory size as a string including a unit .
the memory size as a string, e.g. "10K"
the memory size as a string e . g . " 10K "
String