Skip to content

Instantly share code, notes, and snippets.

@ahmgeek
Created June 3, 2016 23:27
Show Gist options
  • Save ahmgeek/6e89f9636d170b0cd8aa02175fd32037 to your computer and use it in GitHub Desktop.
Save ahmgeek/6e89f9636d170b0cd8aa02175fd32037 to your computer and use it in GitHub Desktop.
Code CracklePop
module Divisable
def divided_by?(num, divisor)
num % divisor == 0
end
end
class CracklePop
include Divisable
def initialize
@num = (1..100).to_a
end
def execute
@num.each do |n|
return "Crackle" if divided_by?(n, 3)
return "Pop" if divided_by?(n, 5)
return "CracklePop" if divided_by?(n, 5) && divided_by?(n, 3)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment