ruby-fizzbuzz 0.0.6 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MWYzNWE4ZTE5NzkyODAwMmM0ZjA5N2UxODZmYmUwNTNmZTI0N2YzNQ==
5
- data.tar.gz: !binary |-
6
- YWRjODkyYmU3MTFkNjQxMWVjOGUxNTQ0YTliZjkyOTgxMDIwMTk3Ng==
2
+ SHA1:
3
+ metadata.gz: 15be72f9c77aaa84d7fa6f92403623aa38d62add
4
+ data.tar.gz: a7b92647afb2cf83ded7bd442829964b09a6a5e5
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MzlmMzNmMDRkYzRmODUxMDRiMTZlNzZmZjMxY2YwYzQyMmVkYTU3YmJiODNk
10
- OTM4OWZlYzQ5YjY4NDEzNGNiNzU5YWUxZDNkN2UwYTRmZDk5ZWJkODU4Y2Jm
11
- Njc3MzVhNTRhNDc5ZGQ0OWFjYjAyM2MyMTM0ZmYxNDI1MmRlZmU=
12
- data.tar.gz: !binary |-
13
- ODE4OGU2ZTU5MTAzNDJkYjVmZGM5MzY1NzBiZWFlOGM3NThjMWY4MDhiNWE5
14
- ZWYxYzljZjIzZDYyYzgyYTNkNTZkNTBlZjk5NjdiZGMwY2RlZTcyNWMwYzM5
15
- ZjAxNDkxM2Y1ZGEwMThkYTI4NWM3MTUwMTRiOGVjNmViNDczMWQ=
6
+ metadata.gz: ca579ce7e2c92319421613c3f9aaaddff506a222682760d52c03701d53da730d0da195eb9d30c4adbc2b4f45e7ee2ab600f9c64a12060244fe069e3595c31550
7
+ data.tar.gz: ae2ba4d86ac6ba15ee7245535f5b797485aef4cee26f713fe3309db983002c0ad85e543b5589518cc2bfeabc2d3b0576f13580861abf3c28eb4d6bc1be275504
data/CHANGES CHANGED
@@ -1,55 +1,76 @@
1
+ fizzbuzz (0.7.0)
2
+
3
+ * Added to_hash, as_json, to_json and from_json (singleton) to the FizzBuzz class.
4
+ * Add rudimentary Vagrantfile that can be used to build a development environment.
5
+ * Re-factored fizzbuzz (singleton) from the FizzBuzz class to speed it up.
6
+ * No longer use of Enumerable#entries in the Array integration, achieving better performance.
7
+ * Correctly return Enumerator when integrating with the Range class.
8
+ * Updated Rakefile to no longer run test before benchmark.
9
+ * Fixed benchmarks concerning Array and Range integration.
10
+ * Retired testing with Ruby 1.9.2 and 2.1.0, and added 2.1.5 on Travis CI.
11
+ * Fixed Travis CI build against Rubinius.
12
+ * Re-factored tests to utilise modern version of the "test-unit" Ruby gem.
13
+ * Fixed build to make it work with C++ compilers.
14
+ * Added the Guard Ruby gem for convenience, with an appropriate Guardfile.
15
+ * Added LLVM (clang) compiler to build with to Travis CI.
16
+ * Fixed version number to comply with Semantic Versioning 2 (http://semver.org/).
17
+ * Re-factored and cleaned up small portions of code and documentation.
18
+ * Removed BitDeli badge.
19
+
20
+ -- Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> Mon, 15 Dec 2014 00:27:26 +0000
21
+
1
22
  fizzbuzz (0.0.6)
2
23
 
3
- * Fixed issue reported by LLVM (clang);
4
- * Updated development dependencies;
5
- * Added Ruby 2.1.0 to Travis CI;
6
- * Added BitDeli and Gemnasium integration;
7
- * Re-factored and cleaned up small portions of code;
8
- * Made Rake "test" task to be the default tasks;
24
+ * Fixed issue reported by LLVM (clang).
25
+ * Updated development dependencies.
26
+ * Added Ruby 2.1.0 to Travis CI.
27
+ * Added BitDeli and Gemnasium integration.
28
+ * Re-factored and cleaned up small portions of code.
29
+ * Made Rake "test" task to be the default tasks.
9
30
  * Updated the ".gitignore" file to cover Bundler, rbenv, etc.
10
31
 
11
32
  -- Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> Sun, 23 Feb 2014 13:52:08 +0000
12
33
 
13
34
  fizzbuzz (0.0.5)
14
35
 
15
- * Added integration with Array and Range types;
36
+ * Added integration with Array and Range types.
16
37
  * Added simple benchmark.
17
38
 
18
39
  -- Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> Tue, 26 Nov 2013 12:40:34 +0000
19
40
 
20
41
  fizzbuzz (0.0.4)
21
42
 
22
- * Retired support for Ruby 1.8.x (no support for MRI, Ruby Enterprise Edition and Rubinius);
23
- * Added Coveralls and Code Climate integration (and hence improved code test coverage);
24
- * Improved error handling and made code more resilient to errors;
43
+ * Retired support for Ruby 1.8.x (no support for MRI, Ruby Enterprise Edition and Rubinius).
44
+ * Added Coveralls and Code Climate integration (and hence improved code test coverage).
45
+ * Improved error handling and made code more resilient to errors.
25
46
  * Fixed formatting and white spaces.
26
47
 
27
48
  -- Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> Mon, 18 Nov 2013 11:22:26 +0000
28
49
 
29
50
  fizzbuzz (0.0.3)
30
51
 
31
- * Added custom exceptions and improved error handling;
32
- * Added more variety of Rubies on which tests are being run with Travis CI;
52
+ * Added custom exceptions and improved error handling.
53
+ * Added more variety of Rubies on which tests are being run with Travis CI.
33
54
  * Added project to Rubygems (http://rubygems.org) so it can be installed
34
- with just "gem install ruby-fizzbuzz" command;
55
+ with just "gem install ruby-fizzbuzz" command.
35
56
  * Renamed project from "fizzbuzz" to "ruby-fizzbuzz" to avoid clashes with
36
- other Ruby gems hosted on Rubygems web site;
57
+ other Ruby gems hosted on Rubygems web site.
37
58
  * Made "mkmf" in extconf.rb more user-friendly (it now reports missing
38
- build-time dependencies better);
59
+ build-time dependencies better).
39
60
  * Split Ruby gem specification (or gemspec if you wish) away from Rakefile
40
- into its own file (namely ruby-fizzbuzz.gemspec);
61
+ into its own file (namely ruby-fizzbuzz.gemspec).
41
62
  * Improved documentation and removed bunch of small code smells.
42
63
 
43
64
  -- Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> Sat, 31 Aug 2013 17:54:54 +0000
44
65
 
45
66
  fizzbuzz (0.0.2)
46
67
 
47
- * Added is_fizz?, is_buzz? and is_fizzbuzz? singleton methods to FizzBuzz class;
68
+ * Added is_fizz?, is_buzz? and is_fizzbuzz? singleton methods to FizzBuzz class.
48
69
  * Added fizz?, buzz? and fizzbuzz? methods to the Integer class via a monkey-patch
49
- for convenience;
70
+ for convenience.
50
71
  * Changed behaviour of the FizzBuzz#[] singleton method, so it will yield a FizzBuzz
51
- result for a given arbitrary Integer value;
52
- * Re-factored code to make it cleaner, and added more tests and improved coverage;
72
+ result for a given arbitrary Integer value.
73
+ * Re-factored code to make it cleaner, and added more tests and improved coverage.
53
74
  * Re-factored FizzBuzz so it now does not assume that we always want to calculate
54
75
  results from 1 to n -- it is now possible to calculate FizzBuzz results for given
55
76
  n, m values, where n denotes start and m denotes stop value.
@@ -1,55 +1,76 @@
1
+ fizzbuzz (0.7.0)
2
+
3
+ * Added to_hash, as_json, to_json and from_json (singleton) to the FizzBuzz class.
4
+ * Add rudimentary Vagrantfile that can be used to build a development environment.
5
+ * Re-factored fizzbuzz (singleton) from the FizzBuzz class to speed it up.
6
+ * No longer use of Enumerable#entries in the Array integration, achieving better performance.
7
+ * Correctly return Enumerator when integrating with the Range class.
8
+ * Updated Rakefile to no longer run test before benchmark.
9
+ * Fixed benchmarks concerning Array and Range integration.
10
+ * Retired testing with Ruby 1.9.2 and 2.1.0, and added 2.1.5 on Travis CI.
11
+ * Fixed Travis CI build against Rubinius.
12
+ * Re-factored tests to utilise modern version of the "test-unit" Ruby gem.
13
+ * Fixed build to make it work with C++ compilers.
14
+ * Added the Guard Ruby gem for convenience, with an appropriate Guardfile.
15
+ * Added LLVM (clang) compiler to build with to Travis CI.
16
+ * Fixed version number to comply with Semantic Versioning 2 (http://semver.org/).
17
+ * Re-factored and cleaned up small portions of code and documentation.
18
+ * Removed BitDeli badge.
19
+
20
+ -- Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> Mon, 15 Dec 2014 00:27:26 +0000
21
+
1
22
  fizzbuzz (0.0.6)
2
23
 
3
- * Fixed issue reported by LLVM (clang);
4
- * Updated development dependencies;
5
- * Added Ruby 2.1.0 to Travis CI;
6
- * Added BitDeli and Gemnasium integration;
7
- * Re-factored and cleaned up small portions of code;
8
- * Made Rake "test" task to be the default tasks;
24
+ * Fixed issue reported by LLVM (clang).
25
+ * Updated development dependencies.
26
+ * Added Ruby 2.1.0 to Travis CI.
27
+ * Added BitDeli and Gemnasium integration.
28
+ * Re-factored and cleaned up small portions of code.
29
+ * Made Rake "test" task to be the default tasks.
9
30
  * Updated the ".gitignore" file to cover Bundler, rbenv, etc.
10
31
 
11
32
  -- Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> Sun, 23 Feb 2014 13:52:08 +0000
12
33
 
13
34
  fizzbuzz (0.0.5)
14
35
 
15
- * Added integration with Array and Range types;
36
+ * Added integration with Array and Range types.
16
37
  * Added simple benchmark.
17
38
 
18
39
  -- Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> Tue, 26 Nov 2013 12:40:34 +0000
19
40
 
20
41
  fizzbuzz (0.0.4)
21
42
 
22
- * Retired support for Ruby 1.8.x (no support for MRI, Ruby Enterprise Edition and Rubinius);
23
- * Added Coveralls and Code Climate integration (and hence improved code test coverage);
24
- * Improved error handling and made code more resilient to errors;
43
+ * Retired support for Ruby 1.8.x (no support for MRI, Ruby Enterprise Edition and Rubinius).
44
+ * Added Coveralls and Code Climate integration (and hence improved code test coverage).
45
+ * Improved error handling and made code more resilient to errors.
25
46
  * Fixed formatting and white spaces.
26
47
 
27
48
  -- Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> Mon, 18 Nov 2013 11:22:26 +0000
28
49
 
29
50
  fizzbuzz (0.0.3)
30
51
 
31
- * Added custom exceptions and improved error handling;
32
- * Added more variety of Rubies on which tests are being run with Travis CI;
52
+ * Added custom exceptions and improved error handling.
53
+ * Added more variety of Rubies on which tests are being run with Travis CI.
33
54
  * Added project to Rubygems (http://rubygems.org) so it can be installed
34
- with just "gem install ruby-fizzbuzz" command;
55
+ with just "gem install ruby-fizzbuzz" command.
35
56
  * Renamed project from "fizzbuzz" to "ruby-fizzbuzz" to avoid clashes with
36
- other Ruby gems hosted on Rubygems web site;
57
+ other Ruby gems hosted on Rubygems web site.
37
58
  * Made "mkmf" in extconf.rb more user-friendly (it now reports missing
38
- build-time dependencies better);
59
+ build-time dependencies better).
39
60
  * Split Ruby gem specification (or gemspec if you wish) away from Rakefile
40
- into its own file (namely ruby-fizzbuzz.gemspec);
61
+ into its own file (namely ruby-fizzbuzz.gemspec).
41
62
  * Improved documentation and removed bunch of small code smells.
42
63
 
43
64
  -- Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> Sat, 31 Aug 2013 17:54:54 +0000
44
65
 
45
66
  fizzbuzz (0.0.2)
46
67
 
47
- * Added is_fizz?, is_buzz? and is_fizzbuzz? singleton methods to FizzBuzz class;
68
+ * Added is_fizz?, is_buzz? and is_fizzbuzz? singleton methods to FizzBuzz class.
48
69
  * Added fizz?, buzz? and fizzbuzz? methods to the Integer class via a monkey-patch
49
- for convenience;
70
+ for convenience.
50
71
  * Changed behaviour of the FizzBuzz#[] singleton method, so it will yield a FizzBuzz
51
- result for a given arbitrary Integer value;
52
- * Re-factored code to make it cleaner, and added more tests and improved coverage;
72
+ result for a given arbitrary Integer value.
73
+ * Re-factored code to make it cleaner, and added more tests and improved coverage.
53
74
  * Re-factored FizzBuzz so it now does not assume that we always want to calculate
54
75
  results from 1 to n -- it is now possible to calculate FizzBuzz results for given
55
76
  n, m values, where n denotes start and m denotes stop value.
data/COPYRIGHT CHANGED
@@ -1 +1 @@
1
- Copyright 2012-2013 Krzysztof Wilczynski
1
+ Copyright 2012-2014 Krzysztof Wilczynski
@@ -5,8 +5,8 @@ Written in C as an example of using Ruby's C API - with the support
5
5
  for arbitrary large numeric values via the Bignum class.
6
6
 
7
7
  {<img src="https://travis-ci.org/kwilczynski/ruby-fizzbuzz.png?branch=master" alt="Build Status"/>}[https://travis-ci.org/kwilczynski/ruby-fizzbuzz]
8
+ {<img src="http://inch-ci.org/github/kwilczynski/ruby-fizzbuzz.svg?branch=master" alt="Documentation Status" />}[http://inch-ci.org/github/kwilczynski/ruby-fizzbuzz]
8
9
  {<img src="https://badge.fury.io/rb/ruby-fizzbuzz.png" alt="Gem Version" />}[http://badge.fury.io/rb/ruby-fizzbuzz]
9
10
  {<img src="https://coveralls.io/repos/kwilczynski/ruby-fizzbuzz/badge.png?branch=master" alt="Coverage Status" />}[https://coveralls.io/r/kwilczynski/ruby-fizzbuzz?branch=master]
10
- {<img src="https://codeclimate.com/github/kwilczynski/ruby-fizzbuzz.png" />}[https://codeclimate.com/github/kwilczynski/ruby-fizzbuzz]
11
+ {<img src="https://codeclimate.com/github/kwilczynski/ruby-fizzbuzz.png" alt="Code Quality" />}[https://codeclimate.com/github/kwilczynski/ruby-fizzbuzz]
11
12
  {<img src="https://gemnasium.com/kwilczynski/ruby-fizzbuzz.png" alt="Dependency Status" />}[https://gemnasium.com/kwilczynski/ruby-fizzbuzz]
12
- {<img src="https://d2weczhvl823v0.cloudfront.net/kwilczynski/ruby-fizzbuzz/trend.png" alt="Bitdeli Badge" />}[https://bitdeli.com/free]
data/Rakefile CHANGED
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # Rakefile
7
7
  #
8
- # Copyright 2012-2013 Krzysztof Wilczynski
8
+ # Copyright 2012-2014 Krzysztof Wilczynski
9
9
  #
10
10
  # Licensed under the Apache License, Version 2.0 (the "License");
11
11
  # you may not use this file except in compliance with the License.
@@ -70,10 +70,8 @@ Rake::ExtensionTask.new('fizzbuzz', gem) do |e|
70
70
  e.lib_dir = 'lib/fizzbuzz'
71
71
  end
72
72
 
73
- Rake::Task[:test].prerequisites << :compile
74
-
75
73
  desc 'Run benchmarks'
76
- task :benchmark, [:first] => :test do |t,argument|
74
+ task :benchmark, [:first] do |t,argument|
77
75
  glob = File.expand_path("../benchmark/*.rb", __FILE__)
78
76
  Dir[glob].each do |f|
79
77
  process = ['ruby', f]
@@ -90,6 +88,9 @@ task :benchmark, [:first] => :test do |t,argument|
90
88
  end
91
89
  end
92
90
 
91
+ Rake::Task[:test].prerequisites << :clobber
92
+ Rake::Task[:test].prerequisites << :compile
93
+
93
94
  task :default => :test
94
95
 
95
96
  # vim: set ts=2 sw=2 sts=2 et :
data/TODO CHANGED
@@ -1,11 +1,11 @@
1
- fizzbuzz (0.0.8)
1
+ fizzbuzz (0.9.0)
2
2
 
3
3
  * Improve github project page;
4
4
  * Re-factor unit tests to make them more idiomatic (maybe move to Rspec and BDD?).
5
5
 
6
- -- Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> Sun, 23 Feb 2014 13:52:08 +0000
6
+ -- Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> Mon, 15 Dec 2014 00:27:26 +0000
7
7
 
8
- fizzbuzz (0.0.7)
8
+ fizzbuzz (0.8.0)
9
9
 
10
10
  * Move to YARD from RDoc (as RDoc is very bad, really);
11
11
  * Add pure-Ruby implementation;
@@ -13,4 +13,4 @@ fizzbuzz (0.0.7)
13
13
  * Add Doxygen style comments for other functions in the source code;
14
14
  * Improve documentation i.e. source code commenting, README file, etc.
15
15
 
16
- -- Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> Sun, 23 Feb 2014 13:52:08 +0000
16
+ -- Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> Mon, 15 Dec 2014 00:27:26 +0000
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.7.0
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # benchmark_fizzbuzz.rb
7
7
  #
8
- # Copyright 2012-2013 Krzysztof Wilczynski
8
+ # Copyright 2012-2014 Krzysztof Wilczynski
9
9
  #
10
10
  # Licensed under the Apache License, Version 2.0 (the "License");
11
11
  # you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@ CAPTION = "%8s%12s%11s%10s\n" % %w(User System Total Real)
37
37
  n = (ARGV.shift || 1_000_000).to_i
38
38
 
39
39
  start = Time.now
40
- array = (1 .. n).to_a
40
+ array = (1..n).to_a
41
41
  reports = []
42
42
 
43
43
  puts "FizzBuzz #{FizzBuzz::VERSION}, n = #{n}\n\n"
@@ -76,11 +76,11 @@ Benchmark.benchmark(CAPTION, 24) do |bm|
76
76
  end
77
77
 
78
78
  reports << bm.report('Array#fizzbuzz') do
79
- (1 .. n).fizzbuzz
79
+ array.fizzbuzz
80
80
  end
81
81
 
82
82
  reports << bm.report('Range#fizzbuzz') do
83
- array.fizzbuzz
83
+ (1..n).fizzbuzz {|i| i }
84
84
  end
85
85
 
86
86
  []
@@ -7,7 +7,7 @@
7
7
  #
8
8
  # fizzbuzz
9
9
  #
10
- # Copyright 2012-2013 Krzysztof Wilczynski
10
+ # Copyright 2012-2014 Krzysztof Wilczynski
11
11
  #
12
12
  # Licensed under the Apache License, Version 2.0 (the "License");
13
13
  # you may not use this file except in compliance with the License.
@@ -3,7 +3,7 @@
3
3
  /*
4
4
  * common.h
5
5
  *
6
- * Copyright 2012-2013 Krzysztof Wilczynski
6
+ * Copyright 2012-2014 Krzysztof Wilczynski
7
7
  *
8
8
  * Licensed under the Apache License, Version 2.0 (the "License");
9
9
  * you may not use this file except in compliance with the License.
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # extconf.rb
7
7
  #
8
- # Copyright 2012-2013 Krzysztof Wilczynski
8
+ # Copyright 2012-2014 Krzysztof Wilczynski
9
9
  #
10
10
  # Licensed under the Apache License, Version 2.0 (the "License");
11
11
  # you may not use this file except in compliance with the License.
@@ -24,10 +24,17 @@ require 'mkmf'
24
24
 
25
25
  RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
26
26
 
27
+ $CFLAGS << ' -std=c99 -g -Wall -Wextra -pedantic'
28
+
29
+ unless RbConfig::CONFIG['host_os'][/darwin/]
30
+ $LDFLAGS << ' -Wl,--as-needed'
31
+ end
32
+
27
33
  $LDFLAGS << " %s" % ENV['LDFLAGS'] if ENV['LDFLAGS']
28
34
 
29
- $CFLAGS << " %s" % ENV['CFLAGS'] if ENV['CFLAGS']
30
- $CFLAGS << ' -std=c99 -g -Wall -Wextra -pedantic'
35
+ %w(CFLAGS CXXFLAGS CPPFLAGS).each do |variable|
36
+ $CFLAGS << " %s" % ENV[variable] if ENV[variable]
37
+ end
31
38
 
32
39
  unless have_header('ruby.h')
33
40
  abort <<-EOS
@@ -3,7 +3,7 @@
3
3
  /*
4
4
  * fizzbuzz.c
5
5
  *
6
- * Copyright 2012-2013 Krzysztof Wilczynski
6
+ * Copyright 2012-2014 Krzysztof Wilczynski
7
7
  *
8
8
  * Licensed under the Apache License, Version 2.0 (the "License");
9
9
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,10 @@
18
18
  * limitations under the License.
19
19
  */
20
20
 
21
+ #if defined(__cplusplus)
22
+ extern "C" {
23
+ #endif
24
+
21
25
  #include <fizzbuzz.h>
22
26
 
23
27
  ID id_at_start, id_at_stop;
@@ -49,7 +53,7 @@ static VALUE fizzbuzz_range_error(VALUE klass, VALUE start, VALUE stop,
49
53
  *
50
54
  * Returns a new _FizzBuzz_.
51
55
  *
52
- * The given +start+ and +stop+ values must be of an integer type and
56
+ * The given +start+ and +stop+ values must be of an _Integer_ type and
53
57
  * will establish a +range+ within which calculation of any relevant
54
58
  * _FizzBuzz_ results will have place.
55
59
  *
@@ -64,7 +68,7 @@ static VALUE fizzbuzz_range_error(VALUE klass, VALUE start, VALUE stop,
64
68
  * exception.
65
69
  *
66
70
  * Will raise a <i>FizzBuzz::TypeError</i> exception if given value of either
67
- * +start+ or +stop+ is not an _Integer_ or _Bignum_ type.
71
+ * +start+ or +stop+ is not an _Fixnum_ or _Bignum_ type.
68
72
  *
69
73
  * See also: FizzBuzz::fizzbuzz and FizzBuzz::[]
70
74
  */
@@ -119,7 +123,7 @@ rb_fb_get_start(VALUE object)
119
123
  * fb.start #=> 15
120
124
  *
121
125
  * Will raise a <i>FizzBuzz::TypeError</i> exception if given value is not
122
- * an _Integer_ or _Bignum_ type.
126
+ * an _Fixnum_ or _Bignum_ type.
123
127
  */
124
128
  VALUE
125
129
  rb_fb_set_start(VALUE object, VALUE value)
@@ -165,7 +169,7 @@ rb_fb_get_stop(VALUE object)
165
169
  * fb.stop #=> 15
166
170
  *
167
171
  * Will raise a <i>FizzBuzz::TypeError</i> exception if given value is not
168
- * an _Integer_ or _Bignum_ type.
172
+ * an _Fixnum_ or _Bignum_ type.
169
173
  */
170
174
  VALUE
171
175
  rb_fb_set_stop(VALUE object, VALUE value)
@@ -211,6 +215,11 @@ rb_fb_array(VALUE object)
211
215
  * Example:
212
216
  *
213
217
  * fb = FizzBuzz.new(1, 15) #=> #<FizzBuzz:0xf722f8ec @stop=15, @start=1>
218
+ * fb.each #=> #<Enumerator: #<FizzBuzz:0x007fc5139e5540 @start=1, @stop=15>:each>
219
+ *
220
+ * Example:
221
+ *
222
+ * fb = FizzBuzz.new(1, 15) #=> #<FizzBuzz:0xf722f8ec @stop=15, @start=1>
214
223
  * fb.each {|value| puts "Got #{value}" }
215
224
  *
216
225
  * Produces:
@@ -248,9 +257,14 @@ rb_fb_enumerator(VALUE object)
248
257
  * from +start+ to +stop+ in an <i>reverse order</i>, passing the value
249
258
  * as a parameter to the block.
250
259
  *
260
+ * If no block is given, an +Enumerator+ is returned instead.
261
+ *
251
262
  * Example:
252
263
  *
253
- * If no block is given, an +Enumerator+ is returned instead.
264
+ * fb = FizzBuzz.new(1, 15) #=> #<FizzBuzz:0xf722f8ec @stop=15, @start=1>
265
+ * fb.each #=> #<Enumerator: #<FizzBuzz:0x007fc513a0de00 @start=1, @stop=15>:reverse_each>
266
+ *
267
+ * Example:
254
268
  *
255
269
  * fb = FizzBuzz.new(1, 15) #=> #<FizzBuzz:0xb7308664 @stop=15, @start=1>
256
270
  * fb.reverse_each {|value| puts "Got #{value}" }
@@ -295,7 +309,7 @@ rb_fb_reverse_enumerator(VALUE object)
295
309
  * FizzBuzz.is_fizz?(15) #=> false
296
310
  *
297
311
  * Will raise a <i>FizzBuzz::TypeError</i> exception if given value is not
298
- * an _Integer_ or _Bignum_ type.
312
+ * an _Fixnum_ or _Bignum_ type.
299
313
  *
300
314
  * See also: FizzBuzz::[]
301
315
  */
@@ -322,7 +336,7 @@ rb_fb_is_fizz(VALUE object, VALUE value)
322
336
  * FizzBuzz.is_buzz?(15) #=> false
323
337
  *
324
338
  * Will raise a <i>FizzBuzz::TypeError</i> exception if given value is not
325
- * an _Integer_ or _Bignum_ type.
339
+ * an _Fixnum_ or _Bignum_ type.
326
340
  *
327
341
  * See also: FizzBuzz::[]
328
342
  */
@@ -349,7 +363,7 @@ rb_fb_is_buzz(VALUE object, VALUE value)
349
363
  * FizzBuzz.is_fizzbuzz?(15) #=> true
350
364
  *
351
365
  * Will raise a <i>FizzBuzz::TypeError</i> exception if given value is not
352
- * an _Integer_ or _Bignum_ type.
366
+ * an _Fixnum_ or _Bignum_ type.
353
367
  *
354
368
  * See also: FizzBuzz::[]
355
369
  */
@@ -379,7 +393,7 @@ rb_fb_is_fizzbuzz(VALUE object, VALUE value)
379
393
  * FizzBuzz[15] #=> "FizzBuzz"
380
394
  *
381
395
  * Will raise a <i>FizzBuzz::TypeError</i> exception if given value is not
382
- * an _Integer_ or _Bignum_ type.
396
+ * an _Fixnum_ or _Bignum_ type.
383
397
  *
384
398
  * See also: FizzBuzz::is_fizz?, FizzBuzz::is_buzz? and FizzBuzz::is_fizzbuzz?
385
399
  */
@@ -407,6 +421,12 @@ fizzbuzz_evaluate(VALUE value)
407
421
  assert((score >= 0 && score <= 3) && \
408
422
  "Score value out of bounds, must be between 0 and 3 inclusive");
409
423
 
424
+ /*
425
+ * The CSTR2RVAL macro uses rb_str_new2(const char *) which is
426
+ * rather slow due to all the heavy lifting done internally by
427
+ * str_new0(VALUE, const char *, long, int) to allocate space
428
+ * for the new String object, etc.
429
+ */
410
430
  return score < 1 ? value : CSTR2RVAL(word(score));
411
431
  }
412
432
 
@@ -554,4 +574,8 @@ Init_fizzbuzz(void)
554
574
  rb_define_singleton_method(rb_cFizzBuzz, "[]", RUBY_METHOD_FUNC(rb_fb_square), 1);
555
575
  }
556
576
 
577
+ #if defined(__cplusplus)
578
+ }
579
+ #endif
580
+
557
581
  /* vim: set ts=8 sw=4 sts=2 et : */