Class: FizzBuzz

Inherits:
Object
  • Object
show all
Defined in:
lib/fizz_buzz.rb

Constant Summary collapse

DEFINITIONS =
{'3' => 'fizz', '5' => 'buzz'}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number) ⇒ FizzBuzz

Returns a new instance of FizzBuzz.



5
6
7
# File 'lib/fizz_buzz.rb', line 5

def initialize(number)
  @number = number
end

Instance Attribute Details

#numberObject

Returns the value of attribute number.



3
4
5
# File 'lib/fizz_buzz.rb', line 3

def number
  @number
end

Instance Method Details

#to_sObject



13
14
15
# File 'lib/fizz_buzz.rb', line 13

def to_s
  convert if valid?
end

#valid?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/fizz_buzz.rb', line 9

def valid?
  number > 0
end