Skip to content

Commit 4955198

Browse files
committed
Simplify section add/remove comment logic
1 parent 906a72b commit 4955198

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

lib/rdoc/code_object/context/section.rb

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,10 @@ def == other
6161
# Adds +comment+ to this section
6262

6363
def add_comment comment
64-
if comment.is_a?(Array)
65-
comment.each do |c|
66-
@comments << extract_comment(c)
67-
end
68-
else
69-
comment = extract_comment(comment)
70-
@comments << comment unless comment.empty?
64+
comments = Array(comment)
65+
comments.each do |c|
66+
extracted_comment = extract_comment(c)
67+
@comments << extracted_comment unless extracted_comment.empty?
7168
end
7269
end
7370

@@ -123,9 +120,7 @@ def hash # :nodoc:
123120
# The files comments in this section come from
124121

125122
def in_files
126-
@comments.map do |comment|
127-
comment.file
128-
end
123+
@comments.map(&:file)
129124
end
130125

131126
##
@@ -171,9 +166,9 @@ def plain_html
171166
# Removes a comment from this section if it is from the same file as
172167
# +comment+
173168

174-
def remove_comment comment
175-
@comments.delete_if do |my_comment|
176-
my_comment.file == comment.file
169+
def remove_comment target_comment
170+
@comments.delete_if do |stored_comment|
171+
stored_comment.file == target_comment.file
177172
end
178173
end
179174

0 commit comments

Comments
 (0)