Skip to content

Instantly share code, notes, and snippets.

@manpages
Last active December 15, 2015 09:28
Show Gist options
  • Save manpages/5238143 to your computer and use it in GitHub Desktop.
Save manpages/5238143 to your computer and use it in GitHub Desktop.
Bit masks with leading zeros in Ruby
def lz(number, symbols=90, arity=2)
unpadded = number.to_s arity
padded = '0' * (symbols - unpadded.length) + unpadded
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment