-
-
Save eamodeorubio/769631 to your computer and use it in GitHub Desktop.
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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ni siquiera lo he probado, ¡ puede que no funcione !