ruby-fizzbuzz 0.7.0 → 0.8.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.
@@ -1,23 +1,3 @@
1
- /* :enddoc: */
2
-
3
- /*
4
- * fizzbuzz.h
5
- *
6
- * Copyright 2012-2014 Krzysztof Wilczynski
7
- *
8
- * Licensed under the Apache License, Version 2.0 (the "License");
9
- * you may not use this file except in compliance with the License.
10
- * You may obtain a copy of the License at
11
- *
12
- * http://www.apache.org/licenses/LICENSE-2.0
13
- *
14
- * Unless required by applicable law or agreed to in writing, software
15
- * distributed under the License is distributed on an "AS IS" BASIS,
16
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- * See the License for the specific language governing permissions and
18
- * limitations under the License.
19
- */
20
-
21
1
  #if !defined(_FIZZBUZZ_H)
22
2
  #define _FIZZBUZZ_H 1
23
3
 
@@ -36,14 +16,15 @@ extern "C" {
36
16
  #define MINUS(a, b) fizzbuzz_minus((a), (b))
37
17
  #define MOD(a, b) fizzbuzz_modulo((a), (b))
38
18
 
39
- #define GREATER(a, b) fizzbuzz_greater((a), (b))
19
+ #define GREATER(a, b) fizzbuzz_greater((a), (b))
40
20
  #define GREATER_EQUAL(a, b) fizzbuzz_greater_equal((a), (b))
41
21
  #define LESS_EQUAL(a, b) fizzbuzz_less_equal((a), (b))
42
22
 
43
- #define INTEGER_P(x) (TYPE(x) == T_FIXNUM || TYPE(x) == T_BIGNUM)
23
+ #define INTEGER_P(x) \
24
+ (RB_TYPE_P((x), T_FIXNUM) || RB_TYPE_P((x), T_BIGNUM))
44
25
 
45
26
  #define ZERO_P(x) \
46
- (FIXNUM_P(x) ? (NUM2TYPE(x) == 0) : fizzbuzz_equal((x), ZERO))
27
+ (FIXNUM_P(x) ? (NUM2TYPE(x) == 0) : fizzbuzz_equal((x), ZERO))
47
28
 
48
29
  #define INCREASE(x) PLUS((x), ONE)
49
30
  #define DECREASE(x) MINUS((x), ONE)
@@ -51,11 +32,11 @@ extern "C" {
51
32
  #define COMPUTE_MOD_3(x) ZERO_P(MOD((x), THREE))
52
33
  #define COMPUTE_MOD_5(x) ZERO_P(MOD((x), FIVE))
53
34
 
54
- #define SCORE_FIXNUM(x) (uint8_t)(!((x) % 3) + 2 * !((x) % 5))
55
- #define SCORE_BIGNUM(x) (uint8_t)(COMPUTE_MOD_3(x) + 2 * COMPUTE_MOD_5(x))
35
+ #define SCORE_FIXNUM(x) (int)(!((x) % 3) + 2 * !((x) % 5))
36
+ #define SCORE_BIGNUM(x) (int)(COMPUTE_MOD_3(x) + 2 * COMPUTE_MOD_5(x))
56
37
 
57
38
  #define SCORE_VALUE(x) \
58
- (FIXNUM_P(x) ? SCORE_FIXNUM(NUM2TYPE(x)) : SCORE_BIGNUM(x))
39
+ (FIXNUM_P(x) ? SCORE_FIXNUM(NUM2TYPE(x)) : SCORE_BIGNUM(x))
59
40
 
60
41
  #define IS_FIZZ(x) (!ZERO_P(x) && (SCORE_VALUE(x) == 1))
61
42
  #define IS_BUZZ(x) (!ZERO_P(x) && (SCORE_VALUE(x) == 2))
@@ -66,157 +47,120 @@ extern "C" {
66
47
  #define LOOP_FORWARD(x) ((x) == D_LOOP_FORWARD)
67
48
  #define LOOP_REVERSE(x) ((x) == D_LOOP_REVERSE)
68
49
 
69
- #define CHECK_TYPE(x, m) \
70
- do { \
71
- if (!INTEGER_P(x)) { \
72
- VALUE __e_type = fizzbuzz_type_error(rb_fb_eTypeError, (m)); \
73
- rb_exc_raise(__e_type); \
74
- } \
50
+ #define CHECK_TYPE(x, m) \
51
+ do { \
52
+ if (!INTEGER_P(x)) \
53
+ rb_exc_raise(fizzbuzz_type_error(rb_fb_eTypeError, (m))); \
75
54
  } while (0)
76
55
 
77
- #define CHECK_RANGE(x, y, m) \
78
- do { \
79
- if (GREATER(x, y)) { \
80
- VALUE __e_range = fizzbuzz_range_error(rb_fb_eRangeError, (x), (y), (m)); \
81
- rb_exc_raise(__e_range); \
82
- } \
56
+ #define CHECK_RANGE(x, y, m) \
57
+ do { \
58
+ if (GREATER(x, y)) \
59
+ rb_exc_raise(fizzbuzz_range_error(rb_fb_eRangeError, (x), (y), (m))); \
83
60
  } while (0)
84
61
 
85
62
  #define error(t) errors[(t)]
86
63
  #define word(n) words[(n) - 1]
87
64
 
88
- enum fizzbuzz_error {
65
+ typedef enum fizzbuzz_error {
89
66
  E_INVALID_TYPE = 0,
90
67
  E_INVALID_START_TYPE,
91
68
  E_INVALID_STOP_TYPE,
92
69
  E_BAD_VALUE_START,
93
70
  E_BAD_VALUE_STOP
94
- };
71
+ } fizzbuzz_error_t;
95
72
 
96
- enum fizzbuzz_return {
73
+ typedef enum fizzbuzz_return {
97
74
  R_TYPE_ARRAY = 0,
98
75
  R_TYPE_ENUMERATOR
99
- };
76
+ } fizzbuzz_return_t;
100
77
 
101
- enum fizzbuzz_direction {
78
+ typedef enum fizzbuzz_direction {
102
79
  D_LOOP_FORWARD = 0,
103
80
  D_LOOP_REVERSE
104
- };
105
-
106
- typedef enum fizzbuzz_return fizzbuzz_return_t;
107
- typedef enum fizzbuzz_direction fizzbuzz_direction_t;
81
+ } fizzbuzz_direction_t;
108
82
 
109
- struct fizzbuzz_exception {
83
+ typedef struct fizzbuzz_exception {
110
84
  VALUE start;
111
85
  VALUE stop;
112
86
  const char *message;
113
87
  VALUE klass;
114
- };
115
-
116
- typedef struct fizzbuzz_exception fizzbuzz_exception_t;
88
+ } fizzbuzz_exception_t;
117
89
 
118
90
  static const char *errors[] = {
91
+ #if defined(HAVE_INTEGER_UNIFICATION)
92
+ "must be an Integer type",
93
+ "must be an Integer type for start",
94
+ "must be an Integer type for stop",
95
+ #else
119
96
  "must be a Fixnum or Bignum type",
120
97
  "must be a Fixnum or Bignum type for start",
121
98
  "must be a Fixnum or Bignum type for stop",
99
+ #endif
122
100
  "start value is higher than stop value",
123
101
  "stop value is lower than start value",
124
102
  NULL
125
103
  };
126
104
 
127
- static const char *words[] = {
128
- "Fizz", "Buzz",
129
- "FizzBuzz", NULL
105
+ static VALUE words[] = {
106
+ Qnil, Qnil, Qnil,
107
+ Qundef
130
108
  };
131
109
 
132
- inline static VALUE
110
+ static VALUE
133
111
  fizzbuzz_plus(VALUE a, VALUE b)
134
112
  {
135
- if (FIXNUM_P(a) && FIXNUM_P(b)) {
136
- return TYPE2NUM(NUM2TYPE(a) + NUM2TYPE(b));
137
- }
138
-
139
- return rb_funcall(a, rb_intern("+"), 1, b);
113
+ return (FIXNUM_P(a) && FIXNUM_P(b)) ? \
114
+ TYPE2NUM(NUM2TYPE(a) + NUM2TYPE(b)) : \
115
+ rb_funcall(a, rb_intern("+"), 1, b);
140
116
  }
141
117
 
142
- inline static VALUE
118
+ static VALUE
143
119
  fizzbuzz_minus(VALUE a, VALUE b)
144
120
  {
145
- if (FIXNUM_P(a) && FIXNUM_P(b)) {
146
- return TYPE2NUM(NUM2TYPE(a) - NUM2TYPE(b));
147
- }
148
-
149
- return rb_funcall(a, rb_intern("-"), 1, b);
121
+ return (FIXNUM_P(a) && FIXNUM_P(b)) ? \
122
+ TYPE2NUM(NUM2TYPE(a) - NUM2TYPE(b)) : \
123
+ rb_funcall(a, rb_intern("-"), 1, b);
150
124
  }
151
125
 
152
- inline static VALUE
126
+ static VALUE
153
127
  fizzbuzz_modulo(VALUE a, VALUE b)
154
128
  {
155
- if (FIXNUM_P(a) && FIXNUM_P(b)) {
156
- return TYPE2NUM(NUM2TYPE(a) % NUM2TYPE(b));
157
- }
158
-
159
- return rb_funcall(a, rb_intern("%"), 1, b);
129
+ return (FIXNUM_P(a) && FIXNUM_P(b)) ? \
130
+ TYPE2NUM(NUM2TYPE(a) % NUM2TYPE(b)) : \
131
+ rb_funcall(a, rb_intern("%"), 1, b);
160
132
  }
161
133
 
162
- inline static VALUE
134
+ static int
163
135
  fizzbuzz_equal(VALUE a, VALUE b)
164
136
  {
165
- VALUE result;
166
-
167
- if (FIXNUM_P(a) && FIXNUM_P(b)) {
168
- result = (NUM2TYPE(a) == NUM2TYPE(b));
169
- }
170
- else {
171
- result = rb_funcall(a, rb_intern("=="), 1, b);
172
- }
173
-
174
- return RVAL2CBOOL(result);
137
+ return RB_LIKELY(FIXNUM_P(a) && FIXNUM_P(b)) ? \
138
+ (NUM2TYPE(a) == NUM2TYPE(b)) : \
139
+ RVAL2CBOOL(rb_funcall(a, rb_intern("=="), 1, b));
175
140
  }
176
141
 
177
- inline static VALUE
142
+ static int
178
143
  fizzbuzz_greater(VALUE a, VALUE b)
179
144
  {
180
- VALUE result;
181
-
182
- if (FIXNUM_P(a) && FIXNUM_P(b)) {
183
- result = (NUM2TYPE(a) > NUM2TYPE(b));
184
- }
185
- else {
186
- result = rb_funcall(a, rb_intern(">"), 1, b);
187
- }
188
-
189
- return RVAL2CBOOL(result);
145
+ return RB_LIKELY(FIXNUM_P(a) && FIXNUM_P(b)) ? \
146
+ (NUM2TYPE(a) > NUM2TYPE(b)) : \
147
+ RVAL2CBOOL(rb_funcall(a, rb_intern(">"), 1, b));
190
148
  }
191
149
 
192
- inline static VALUE
150
+ static int
193
151
  fizzbuzz_greater_equal(VALUE a, VALUE b)
194
152
  {
195
- VALUE result;
196
-
197
- if (FIXNUM_P(a) && FIXNUM_P(b)) {
198
- result = (NUM2TYPE(a) >= NUM2TYPE(b));
199
- }
200
- else {
201
- result = rb_funcall(a, rb_intern(">="), 1, b);
202
- }
203
-
204
- return RVAL2CBOOL(result);
153
+ return RB_LIKELY(FIXNUM_P(a) && FIXNUM_P(b)) ? \
154
+ (NUM2TYPE(a) >= NUM2TYPE(b)) : \
155
+ RVAL2CBOOL(rb_funcall(a, rb_intern(">="), 1, b));
205
156
  }
206
157
 
207
- inline static VALUE
158
+ static int
208
159
  fizzbuzz_less_equal(VALUE a, VALUE b)
209
160
  {
210
- VALUE result;
211
-
212
- if (FIXNUM_P(a) && FIXNUM_P(b)) {
213
- result = (NUM2TYPE(a) <= NUM2TYPE(b));
214
- }
215
- else {
216
- result = rb_funcall(a, rb_intern("<="), 1, b);
217
- }
218
-
219
- return RVAL2CBOOL(result);
161
+ return RB_LIKELY(FIXNUM_P(a) && FIXNUM_P(b)) ? \
162
+ (NUM2TYPE(a) <= NUM2TYPE(b)) : \
163
+ RVAL2CBOOL(rb_funcall(a, rb_intern("<="), 1, b));
220
164
  }
221
165
 
222
166
  RUBY_EXTERN ID id_at_start, id_at_stop;
@@ -249,5 +193,3 @@ RUBY_EXTERN VALUE rb_fb_square(VALUE object, VALUE value);
249
193
  #endif
250
194
 
251
195
  #endif /* _FIZZBUZZ_H */
252
-
253
- /* vim: set ts=8 sw=4 sts=2 et : */
@@ -0,0 +1,25 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEIDCCAoigAwIBAgIBATANBgkqhkiG9w0BAQsFADAdMRswGQYDVQQDDBJrdy9E
3
+ Qz1saW51eC9EQz1jb20wHhcNMTkwODAzMTUzOTEzWhcNMjAwODAyMTUzOTEzWjAd
4
+ MRswGQYDVQQDDBJrdy9EQz1saW51eC9EQz1jb20wggGiMA0GCSqGSIb3DQEBAQUA
5
+ A4IBjwAwggGKAoIBgQCroSgHc4BNx1gFHRHBbLvyKbsQPoa8uZVUbQ4uXuI9URdR
6
+ Uho84FcXnFOLjWaTHXX6aG9OI08zWSwV0mcg19PZakjqbdUw8WAGvBnpkwFNz/gG
7
+ J46+T+BDQ0gLWuoMLYEAOjUcRqcaMUgsspUXpKCbbtBId782yieyKsCWDgBxtUZd
8
+ 5jPgrAEpOW8C1p8K+MlNXjBvib/K5ODk28BqGcKGa0udRJ9yfD/k4MczUcRGgaNg
9
+ Pno2ncH8Jw/Dcfy4gZgHKsTGCtqOQbsKc5G5u0hDgIGJ6FVvR620TUPGvpFUG1A/
10
+ otGkdoe6MDLciUbJmYIr6I3ykNF+IWmPmZCHsOKd9a7neVk+TGJQYiKo74XG9cbo
11
+ Ms8HQomJTNWMM0csu0fWq/jB0T2Lbg9N1gjJ4neR82CwE1galmWCNguD7EVO+axn
12
+ nFrxCnT9Lc1YvyJMfx1Rr+guC/S2LMY/GgSwxiSwt7eh+AGv5tfgNdHuFyFHNFrz
13
+ pAdaz5CqFRalQkZ169ECAwEAAaNrMGkwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
14
+ HQYDVR0OBBYEFPa4Bg07AC8HR7uy6WCYWXP8wLGwMBcGA1UdEQQQMA6BDGt3QGxp
15
+ bnV4LmNvbTAXBgNVHRIEEDAOgQxrd0BsaW51eC5jb20wDQYJKoZIhvcNAQELBQAD
16
+ ggGBAEBJuRhodAsjx52dYS/9tKTCbXOoGH1qYYiGHWVXCt2ZJYXB34bTWjqpT7w9
17
+ dw/I0HydvKk8kYs3LWDDmg6hDIPJ5Br4+sadBD1r5dBhpY3WNkMHoTziOTiNr+Pw
18
+ GqF0vWVmZ704XX2S2jzu05EWefDQ+wnMzfevx8hEGIvg2P/d7z3wxce2TvsrpBBY
19
+ iocpBLUiK0EVHBf1BvgC/V01i9xGNg7KdN2dVfLoLSyvrB5MV3ITxiKgrIU0xi6v
20
+ J1KaY5b2N5ZnZaN8cTs5Z0skUkUqPQPFxQL5SM9LyK5gVT2qcF8QhChst8RCUXz9
21
+ 3DdMAGkSExtG/qLRnpPwBszjGZqASIi/OJ9QsAESmMExgwqH1bYAoGNQ60V7iiI0
22
+ Vygrj8cyzqtclWVwszcoLCcEPQW0S4sXmIuvIQ9Uc6UuKM4mHkNTMvSjNSShdAkA
23
+ 7/RnMCIYLU7PievOwRMbF7/22H+PSuMW6/JqGRYk8pph//oNh1EoNFqu7h+bV0Ph
24
+ Y0aXRQ==
25
+ -----END CERTIFICATE-----
@@ -1,35 +1,15 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- # :stopdoc:
4
-
5
- #
6
- # fizzbuzz.rb
7
- #
8
- # Copyright 2012-2014 Krzysztof Wilczynski
9
- #
10
- # Licensed under the Apache License, Version 2.0 (the "License");
11
- # you may not use this file except in compliance with the License.
12
- # You may obtain a copy of the License at
13
- #
14
- # http://www.apache.org/licenses/LICENSE-2.0
15
- #
16
- # Unless required by applicable law or agreed to in writing, software
17
- # distributed under the License is distributed on an "AS IS" BASIS,
18
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
- # See the License for the specific language governing permissions and
20
- # limitations under the License.
21
- #
22
-
23
- # :startdoc:
24
-
25
- gem 'json', '>= 1.8.1'
1
+ # frozen_string_literal: true
26
2
 
27
3
  require 'json'
28
4
 
29
5
  require_relative 'fizzbuzz/fizzbuzz'
30
6
  require_relative 'fizzbuzz/version'
31
7
  require_relative 'fizzbuzz/core/integer'
32
- require_relative 'fizzbuzz/core/bignum'
8
+
9
+ unless 0.class == Integer
10
+ require_relative 'fizzbuzz/core/bignum'
11
+ end
12
+
33
13
  require_relative 'fizzbuzz/core/array'
34
14
  require_relative 'fizzbuzz/core/range'
35
15
 
@@ -54,8 +34,8 @@ class FizzBuzz
54
34
  #
55
35
  # Example:
56
36
  #
57
- # FizzBuzz.fizzbuzz(1, 15) #=> [1, 2, "Fizz", 4, "Buzz", "Fizz", 7, 8, "Fizz", "Buzz", 11, "Fizz", 13, 14, "FizzBuzz"]
58
- # FizzBuzz.fizzbuzz(1, 15, true) #=> ["FizzBuzz", 14, 13, "Fizz", 11, "Buzz", "Fizz", 8, 7, "Fizz", "Buzz", 4, "Fizz", 2, 1]
37
+ # FizzBuzz.fizzbuzz(1, 15) #=> [1, 2, "Fizz", 4, "Buzz", "Fizz", 7, 8, "Fizz", "Buzz", 11, "Fizz", 13, 14, "FizzBuzz"]
38
+ # FizzBuzz.fizzbuzz(1, 15, true) #=> ["FizzBuzz", 14, 13, "Fizz", 11, "Buzz", "Fizz", 8, 7, "Fizz", "Buzz", 4, "Fizz", 2, 1]
59
39
  #
60
40
  # Example:
61
41
  #
@@ -92,6 +72,97 @@ class FizzBuzz
92
72
  end
93
73
  end
94
74
 
75
+ #
76
+ # call-seq:
77
+ # FizzBuzz.step( start, stop, step ) {|value| block } -> an integer
78
+ # FizzBuzz.step( start, stop, step ) -> an Enumerator
79
+ #
80
+ # Calls the block _once_ for each subsequent value for a given range
81
+ # from +start+ to +stop+, passing the value as a parameter to the block
82
+ # in the increments of +step+.
83
+ #
84
+ # If no block is given, an +Enumerator+ is returned instead.
85
+ #
86
+ # Example:
87
+ #
88
+ # s = FizzBuzz.step #=> #<Enumerator: #<Enumerator::Generator:0x559db8e7>:each>
89
+ # s.take(15).each {|value| puts "Got #{value}" }
90
+ #
91
+ # Produces:
92
+ #
93
+ # Got 1
94
+ # Got 2
95
+ # Got Fizz
96
+ # Got 4
97
+ # Got Buzz
98
+ # Got Fizz
99
+ # Got 7
100
+ # Got 8
101
+ # Got Fizz
102
+ # Got Buzz
103
+ # Got 11
104
+ # Got Fizz
105
+ # Got 13
106
+ # Got 14
107
+ # Got FizzBuzz
108
+ #
109
+ # See also: FizzBuzz::fizzbuzz, FizzBuzz::[] and FizzBuzz#step
110
+ #
111
+ def self.step(start = 1, stop = nil, step = 1, &block)
112
+ if block_given?
113
+ start.step(stop, step) do |n|
114
+ yield FB[n]
115
+ end
116
+ else
117
+ Enumerator.new do |y|
118
+ start.step(stop, step).each do |n|
119
+ y << FB[n]
120
+ end
121
+ end
122
+ end
123
+ end
124
+
125
+ #
126
+ # call-seq:
127
+ # fizzbuzz.step( start, stop, step ) {|value| block } -> an integer
128
+ # fizzbuzz.step( start, stop, step ) -> an Enumerator
129
+ #
130
+ # Calls the block _once_ for each subsequent value for a given range
131
+ # from +start+ to +stop+, passing the value as a parameter to the block
132
+ # in the increments of +step+.
133
+ #
134
+ # If no block is given, an +Enumerator+ is returned instead.
135
+ #
136
+ # Example:
137
+ #
138
+ # fb = FizzBuzz.new(1, 15) #=> #<FizzBuzz:0x5653a2d1 @start=1, @stop=15>
139
+ # s = fb.step #=> #<Enumerator: #<Enumerator::Generator:0x559db8e7>:each>
140
+ # s.take(15).each {|value| puts "Got #{value}" }
141
+ #
142
+ # Produces:
143
+ #
144
+ # Got 1
145
+ # Got 2
146
+ # Got Fizz
147
+ # Got 4
148
+ # Got Buzz
149
+ # Got Fizz
150
+ # Got 7
151
+ # Got 8
152
+ # Got Fizz
153
+ # Got Buzz
154
+ # Got 11
155
+ # Got Fizz
156
+ # Got 13
157
+ # Got 14
158
+ # Got FizzBuzz
159
+ #
160
+ # See also: FizzBuzz::step, FizzBuzz::fizzbuzz and FizzBuzz::[]
161
+ #
162
+ def step(start = @start, stop = @stop, step = 1, &block)
163
+ self.class.step(start, stop, step, &block)
164
+ end
165
+
95
166
  #
96
167
  # call-seq:
97
168
  # fizzbuzz.to_hash -> hash
@@ -100,7 +171,7 @@ class FizzBuzz
100
171
  #
101
172
  # Example:
102
173
  #
103
- # fb = FizzBuzz.new(1, 15) #=> #<FizzBuzz:0x007fbe84 @start=1, @stop=15>
174
+ # fb = FizzBuzz.new(1, 15) #=> #<FizzBuzz:0x007fbe84 @start=1, @stop=15>
104
175
  # fb.to_hash
105
176
  #
106
177
  # Produces:
@@ -125,14 +196,14 @@ class FizzBuzz
125
196
 
126
197
  #
127
198
  # call-seq:
128
- # fizzbuzz.as_json -> hash
199
+ # fizzbuzz.as_json( arguments ) -> hash
129
200
  #
130
201
  # Returns a +hash+ representing the _FizzBuzz_ object that will be
131
202
  # used when generating a _JSON_ string representation.
132
203
  #
133
204
  # Example:
134
205
  #
135
- # fb = FizzBuzz.new(1, 15) #=> #<FizzBuzz:0x007f90c1 @start=1, @stop=15>
206
+ # fb = FizzBuzz.new(1, 15) #=> #<FizzBuzz:0x007f90c1 @start=1, @stop=15>
136
207
  # fb.as_json
137
208
  #
138
209
  # Produces:
@@ -147,19 +218,19 @@ class FizzBuzz
147
218
  #
148
219
  # See also: FizzBuzz#to_json and FizzBuzz#to_hash
149
220
  #
150
- def as_json(*arguments)
221
+ def as_json(*)
151
222
  { JSON.create_id => self.class.name }.merge(to_hash)
152
223
  end
153
224
 
154
225
  #
155
226
  # call-seq:
156
- # fizzbuzz.to_json -> string
227
+ # fizzbuzz.to_json( arguments ) -> string
157
228
  #
158
229
  # Returns a _JSON_ string representing the _FizzBuzz_ object.
159
230
  #
160
231
  # Example:
161
232
  #
162
- # fb = FizzBuzz.new(1, 15) #=> #<FizzBuzz:0x007fce83 @start=1, @stop=15>
233
+ # fb = FizzBuzz.new(1, 15) #=> #<FizzBuzz:0x007fce83 @start=1, @stop=15>
163
234
  # fb.to_json
164
235
  #
165
236
  # Produces:
@@ -198,7 +269,7 @@ class FizzBuzz
198
269
  # }
199
270
  # EOS
200
271
  #
201
- # fb = JSON.load(json) #=> #<FizzBuzz:0x007fc082 @start=1, @stop=15>
272
+ # fb = JSON.load(json) #=> #<FizzBuzz:0x007fc082 @start=1, @stop=15>
202
273
  # fb.to_hash
203
274
  #
204
275
  # Produces:
@@ -219,9 +290,4 @@ class FizzBuzz
219
290
  alias_method :to_h, :to_hash
220
291
  end
221
292
 
222
- # :enddoc:
223
-
224
293
  FB = FizzBuzz
225
-
226
- # vim: set ts=2 sw=2 sts=2 et :
227
- # encoding: utf-8