309 shaares
162 liens privés
162 liens privés
2 résultats
taggé
binary
# binary_multpile_of_4?(s)
# that takes a string and returns true
#if the string represents a binary number that is a multiple of 4.
#NOTE: be sure it returns false if the string is not a valid binary number!
def binary_multiple_of_4?(s)
return true if s == "0"
s =~ /^[01]+00$/
end
Only works with ruby 2.2.2 for now.
Source is here : https://github.com/loureirorg/rb2exe
Also works with rails apparently.
I have not tested this gem. But it's worth mentioning it exists.
And yes... this is not a snippet