Skip to content

Instantly share code, notes, and snippets.

@ybur-yug
Last active August 29, 2015 14:19
Show Gist options
  • Save ybur-yug/c5733c2a486197bdc59b to your computer and use it in GitHub Desktop.
Save ybur-yug/c5733c2a486197bdc59b to your computer and use it in GitHub Desktop.
CracklePop
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