Last active
August 29, 2015 14:19
-
-
Save ybur-yug/c5733c2a486197bdc59b to your computer and use it in GitHub Desktop.
CracklePop
This file contains 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
NUMS = (1..100).to_a | |
module CracklePop | |
class Crackler | |
def initialize nums | |
crackle_pop nums | |
end | |
def check_num num | |
if num % 3 == 0 && num % 5 == 0 | |
'CracklePop' | |
elsif num % 5 == 0 | |
'Pop' | |
elsif num % 3 == 0 | |
'Crackle' | |
else | |
num | |
end | |
end | |
def crackle_pop nums | |
nums.map { |n| check_num n }.each { |n| puts n } | |
end | |
end | |
end | |
CracklePop::Crackler.new(NUMS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment