Skip to content

Instantly share code, notes, and snippets.

@maxwellE
Last active December 14, 2015 12:39

Revisions

  1. maxwellE revised this gist Mar 5, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion fizz_buzz.rb
    Original file line number Diff line number Diff line change
    @@ -16,4 +16,5 @@ def evaluate
    end
    end
    end
    end
    end
    puts FizzBuzz.new(1,100).evaluate
  2. maxwellE revised this gist Mar 5, 2013. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions fizz_buzz.rb
    Original file line number Diff line number Diff line change
    @@ -6,13 +6,13 @@ def initialize(lower_bound,upper_bound)
    def evaluate
    (@lower_bound..@upper_bound).map do |x|
    if (x % 5) == 0 && (x % 3) == 0
    "FizzBuzz"
    "FizzBuzz"
    elsif (x % 5) == 0
    "Buzz"
    "Buzz"
    elsif (x % 3) == 0
    "Fizz"
    "Fizz"
    else
    x.to_s
    x.to_s
    end
    end
    end
  3. maxwellE created this gist Mar 5, 2013.
    19 changes: 19 additions & 0 deletions fizz_buzz.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    class FizzBuzz
    def initialize(lower_bound,upper_bound)
    @lower_bound = lower_bound
    @upper_bound = upper_bound
    end
    def evaluate
    (@lower_bound..@upper_bound).map do |x|
    if (x % 5) == 0 && (x % 3) == 0
    "FizzBuzz"
    elsif (x % 5) == 0
    "Buzz"
    elsif (x % 3) == 0
    "Fizz"
    else
    x.to_s
    end
    end
    end
    end