Class: FizzBuzzer::V4::Fizznum
- Inherits:
-
Object
- Object
- FizzBuzzer::V4::Fizznum
- Defined in:
- lib/fizzbuzzer.rb
Instance Method Summary collapse
- #buzz? ⇒ Boolean
- #fizz? ⇒ Boolean
- #fizzbuzz? ⇒ Boolean
-
#initialize(n) ⇒ Fizznum
constructor
A new instance of Fizznum.
- #val ⇒ Object
Constructor Details
#initialize(n) ⇒ Fizznum
Returns a new instance of Fizznum.
110 111 112 |
# File 'lib/fizzbuzzer.rb', line 110 def initialize(n) @n = n end |
Instance Method Details
#buzz? ⇒ Boolean
116 |
# File 'lib/fizzbuzzer.rb', line 116 def buzz?() @n % 5 == 0; end |
#fizz? ⇒ Boolean
115 |
# File 'lib/fizzbuzzer.rb', line 115 def fizz?() @n % 3 == 0; end |
#fizzbuzz? ⇒ Boolean
114 |
# File 'lib/fizzbuzzer.rb', line 114 def fizzbuzz?() @n % 3 == 0 && @n % 5 == 0; end |
#val ⇒ Object
118 119 120 121 122 123 124 |
# File 'lib/fizzbuzzer.rb', line 118 def val if fizzbuzz? then "FizzBuzz" elsif fizz? then "Fizz" elsif buzz? then "Buzz" else @n end end |