app/helpers/number_helper.rb
# Converts in a similar manner as number_to_human_size, but in units of MHz
Converts in a similar manner as number_to_human_size, but in units of MHz
Converts in a similar manner as number_to_human_size but in units of MHz
def mhz_to_human_size(size, *args)
    precision = args.first
    precision = precision[:precision] if precision.kind_of?(Hash)
    precision ||= 1
    NumberHelper.handling_negatives(size) do |s|
      s = s.abs * 1000**2
      if s < 1000**3
        "%.#{precision}f MHz" % (s / (1000**2))
      elsif s < 1000**4
        "%.#{precision}f GHz" % (s / (1000**3))
      else
        "%.#{precision}f THz" % (s / (1000**4))
      end.sub(".%0#{precision}d" % 0, '')
    end
  rescue
    nil
  end
def mhz_to_human_size ( size , * args ) precision = args . first precision = precision [ :precision ] if precision . kind_of? ( Hash ) precision ||= 1 NumberHelper . handling_negatives ( size ) do | s | s = s . abs * 1000 ** 2 if s < 1000 ** 3 "%.#{precision}f MHz" % ( s / ( 1000 ** 2 ) ) elsif s < 1000 ** 4 "%.#{precision}f GHz" % ( s / ( 1000 ** 3 ) ) else "%.#{precision}f THz" % ( s / ( 1000 ** 4 ) ) end . sub ( ".%0#{precision}d" % 0 , '' ) end rescue nil end
Converts in a similar manner as number_to_human_size, but in units of MHz
Converts in a similar manner as number_to_human_size but in units of MHz
size
<not_specific>
args
<not_specific>