Skip to content

Commit 8841721

Browse files
committed
Extract helper to remove explicit block param
1 parent 02c04b1 commit 8841721

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/rdoc/code_object/any_method.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,7 @@ def param_list
255255
end
256256

257257
if @block_params then
258-
# If this method has explicit block parameters, remove any explicit
259-
# &block
260-
params = params.sub(/,?\s*&\w+/, '')
258+
params = remove_explicit_block_param(params)
261259
else
262260
params = params.sub(/\&(\w+)/, '\1')
263261
end
@@ -285,9 +283,7 @@ def param_seq
285283
end
286284

287285
if @block_params then
288-
# If this method has explicit block parameters, remove any explicit
289-
# &block
290-
params = params.sub(/,?\s*&\w+/, '')
286+
params = remove_explicit_block_param(params)
291287

292288
block = @block_params.tr_s("\n ", " ")
293289
if block[0] == ?(
@@ -344,6 +340,13 @@ def _call_seq
344340

345341
private
346342

343+
##
344+
# Removes the explicit &block parameter if the method has explicit block parameters
345+
346+
def remove_explicit_block_param(params)
347+
params.sub(/,?\s*&\w+/, '')
348+
end
349+
347350
##
348351
# call_seq with alias examples information removed, if this
349352
# method is an alias method.

0 commit comments

Comments
 (0)