fizz-buzz 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fizz-buzz}
8
- s.version = "0.4.0"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kerri Miller"]
12
- s.date = %q{2011-11-29}
12
+ s.date = %q{2012-01-11}
13
13
  s.description = %q{I got sick of doing this test in interviews, so next time someone asks me to do so, I'm going to instead hand them a business card with a URL for this gem on it.}
14
14
  s.email = %q{kerrizor@kerrizor.com}
15
15
  s.extra_rdoc_files = [
@@ -1,12 +1,8 @@
1
- class FizzBuzz
2
-
3
- # Returns an array solving the classic 1 to 100 FizzBuzz problem.
4
- def crunch(start=1, stop=100)
5
- return nil unless start < stop
6
-
1
+ module FizzBuzz
2
+ def fizzbuzz
7
3
  return_values = Array.new
8
4
 
9
- (start..stop).each do |n|
5
+ self.each do |n|
10
6
  if n.fizzbuzz?
11
7
  return_values << "FizzBuzz"
12
8
  elsif n.buzz?
@@ -23,7 +19,7 @@ class FizzBuzz
23
19
  end
24
20
 
25
21
 
26
- module FizzBuzziness
22
+ module FizzBuzzNumerics
27
23
  # For testing the Fizz-, Buzz-, or Fizzbuzz-ness of a Fixnum
28
24
  # 3.fizz? # => true
29
25
  # 3.buzz? # => false
@@ -45,13 +41,19 @@ module FizzBuzziness
45
41
  end
46
42
 
47
43
 
48
- class Fixnum
49
- include FizzBuzziness
44
+ class Range
45
+ include FizzBuzz
46
+ end
47
+
48
+
49
+ class Array
50
+ include FizzBuzz
50
51
  end
51
52
 
52
53
 
53
- class Float
54
- include FizzBuzziness
54
+ class Numeric
55
+ include FizzBuzzNumerics
55
56
  end
56
57
 
57
58
 
59
+
@@ -2,36 +2,36 @@ require 'helper'
2
2
 
3
3
  class TestFizzBuzz < Test::Unit::TestCase
4
4
 
5
- def test_new_fizzbuzz
6
- assert_instance_of FizzBuzz, FizzBuzz.new
7
- end
8
-
9
-
10
5
  def setup
11
- @fizzbuzz = FizzBuzz.new
6
+ @fizzbuzz_range = (1..100).fizzbuzz
7
+ @fizzbuzz_array = Array(1..100).fizzbuzz
12
8
  end
13
9
 
10
+ def test_generic_fizzbuzz
11
+ assert_respond_to Array.new, :fizzbuzz
12
+ assert_respond_to Numeric.new, :fizz?
13
+ end
14
14
 
15
- def test_crunch
16
- assert_respond_to @fizzbuzz, :crunch
17
- assert_kind_of Array, @fizzbuzz.crunch
15
+ def test_fizzbuzz_range
16
+ assert_respond_to @fizzbuzz_range, :fizzbuzz
17
+ assert_kind_of Array, @fizzbuzz_range
18
18
 
19
- assert_equal 100, @fizzbuzz.crunch.length
20
- assert_equal "Fizz", @fizzbuzz.crunch[2]
21
- assert_equal "4", @fizzbuzz.crunch[3].to_s
22
- assert_equal "Buzz", @fizzbuzz.crunch[4]
23
- assert_equal "FizzBuzz", @fizzbuzz.crunch[14]
19
+ assert_equal 100, @fizzbuzz_range.length
20
+ assert_equal "Fizz", @fizzbuzz_range[2]
21
+ assert_equal "4", @fizzbuzz_range[3].to_s
22
+ assert_equal "Buzz", @fizzbuzz_range[4]
23
+ assert_equal "FizzBuzz", @fizzbuzz_range[14]
24
24
  end
25
25
 
26
+ def test_fizzbuzz_array
27
+ assert_respond_to @fizzbuzz_array, :fizzbuzz
28
+ assert_kind_of Array, @fizzbuzz_array
26
29
 
27
- def test_crunch_with_range
28
- assert_equal 14, @fizzbuzz.crunch(4,17).length
29
- assert_equal "Fizz", @fizzbuzz.crunch(4,17)[2]
30
- assert_equal "4", @fizzbuzz.crunch(4,17)[0].to_s
31
- assert_equal "Buzz", @fizzbuzz.crunch(4,17)[1]
32
- assert_equal "FizzBuzz", @fizzbuzz.crunch(4,17)[11]
33
-
34
- assert_nil @fizzbuzz.crunch(44,17)
30
+ assert_equal 100, @fizzbuzz_array.length
31
+ assert_equal "Fizz", @fizzbuzz_array[2]
32
+ assert_equal "4", @fizzbuzz_array[3].to_s
33
+ assert_equal "Buzz", @fizzbuzz_array[4]
34
+ assert_equal "FizzBuzz", @fizzbuzz_array[14]
35
35
  end
36
36
 
37
37
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fizz-buzz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-29 00:00:00.000000000 -08:00
12
+ date: 2012-01-11 00:00:00.000000000 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: shoulda
17
- requirement: &2181108320 !ruby/object:Gem::Requirement
17
+ requirement: &2167207300 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *2181108320
25
+ version_requirements: *2167207300
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: bundler
28
- requirement: &2181107840 !ruby/object:Gem::Requirement
28
+ requirement: &2167206820 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 1.0.0
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2181107840
36
+ version_requirements: *2167206820
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: jeweler
39
- requirement: &2181107360 !ruby/object:Gem::Requirement
39
+ requirement: &2167206340 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 1.6.4
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2181107360
47
+ version_requirements: *2167206340
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rcov
50
- requirement: &2181106880 !ruby/object:Gem::Requirement
50
+ requirement: &2167205860 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,7 +55,7 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2181106880
58
+ version_requirements: *2167205860
59
59
  description: I got sick of doing this test in interviews, so next time someone asks
60
60
  me to do so, I'm going to instead hand them a business card with a URL for this
61
61
  gem on it.
@@ -94,7 +94,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
94
  version: '0'
95
95
  segments:
96
96
  - 0
97
- hash: -226548314513455172
97
+ hash: 2225280517144778850
98
98
  required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  none: false
100
100
  requirements: