Method: Win32::Clipboard.zeroFmt

Defined in:
lib/htmlclipboard.rb

.zeroFmt(nbr) ⇒ Object

zeroFmt(nbr)

--  Takes a number and formats with zero's in front.
    1234 => "0000001234"
    23   => "0000000023"


23
24
25
26
27
# File 'lib/htmlclipboard.rb', line 23

def self.zeroFmt(nbr)
  zeros = "0"*10
  len = nbr.to_s.length        # this is the number of digits in the number  2784 => 4

  return zeros.slice(0..(zeros.length - len - 1)) + nbr.to_s
end