Created
August 30, 2011 23:24
-
-
Save jtadeulopes/1182380 to your computer and use it in GitHub Desktop.
ruby exercícios
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Deve completar a máscara de acordo com o número informado | |
# | |
mask("125") | |
=> "00012-500" | |
mask("385002") | |
=> "38500-200" | |
mask("38500201") | |
=> "38500-201" } | |
mask("2950") | |
=> "00295-000" | |
mask("22923") | |
=> "02292-300" | |
mask("7603725") | |
=> "76037-250" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Não deve aceitar meses consecutivos dentro do mesmo ano | |
# | |
valid = ["01/2012", "04/2012", "07/2012", "10/2012"] | |
invalid = ["01/2012", "04/2012", "07/2012", "08/2012"] | |
valid_2 = ["01/2012", "04/2012", "02/2013", "05/2013"] | |
invalid_2 = ["02/2012", "01/2012"] | |
valid_months?(valid) | |
=> true | |
valid_months?(invalid) | |
=> false | |
valid_months?(valid_2) | |
=> true | |
valid_months?(invalid_2) | |
=> false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment