Skip to content

Instantly share code, notes, and snippets.

@eamodeorubio
Forked from jacegu/fizzbuzz4.rb
Created January 7, 2011 15:57
Show Gist options
  • Save eamodeorubio/769631 to your computer and use it in GitHub Desktop.
Save eamodeorubio/769631 to your computer and use it in GitHub Desktop.
module FizzBuzzGame
class Number
def initialize(number)
@value= number
end
def answer_for
return FIZZBUZZ if divisible_by?(3) and divisible_by?(5)
return FIZZ if divisible_by?(3)
return BUZZ if divisible_by?(5)
number
end
private:
FIZZ = 'fizz'
BUZZ = 'buzz'
FIZZBUZZ = 'fizzbuzz'
def divisible_by?(n)
@value % n == 0
end
end
def answer_for(number)
FizzBuzzGame::Number.new(number).answer_for
end
end
@eamodeorubio
Copy link
Author

Ni siquiera lo he probado, ¡ puede que no funcione !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment