Sha256: d5d5f3d6750a9a45ef0bfc2dc9f1e4cbc35d758a02bcc3273375edb87bfe23b8

Contents?: true

Size: 718 Bytes

Versions: 1

Compression:

Stored size: 718 Bytes

Contents

require "bradley_fizzbuzz/version"

module BradleyFizzbuzz
  def fizzbuzz
    array = Array.new
    
    self.each do |n|
      if n.fizzbuzz?
        array << "fizzbuzz"
      elsif n.buzz?
        array << "buzz"
      elsif n.fizz?
        array << "fizz"
      else
        array << n
      end
    end
    
    array
  end
  
  def print_fizzbuzz
    self.fizzbuzz.each do |value| 
      puts value
    end
  end
end

module FizzBuzzNumerics
  def fizz?
    self % 3 == 0
  end
  
  def buzz?
    self % 5 == 0
  end
  
  def fizzbuzz?
    self % 5 == 0 && self % 3 == 0
  end
end

class Numeric
  include FizzBuzzNumerics
end

class Array
  include BradleyFizzbuzz
end

class Range
  include BradleyFizzbuzz
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bradley_fizzbuzz-0.0.1 lib/bradley_fizzbuzz.rb