@@ -61,19 +61,13 @@ def == other
6161  # Adds +comment+ to this section 
6262
6363  def  add_comment  comment 
64-     comment  =  extract_comment  comment 
65- 
66-     return  if  comment . empty? 
67- 
68-     case  comment 
69-     when  RDoc ::Comment  then 
70-       @comments  << comment 
71-     when  RDoc ::Markup ::Document  then 
72-       @comments . concat  comment . parts 
73-     when  Array  then 
74-       @comments . concat  comment 
64+     if  comment . is_a? ( Array ) 
65+       comment . each  do  |c |
66+         @comments  << extract_comment ( c ) 
67+       end 
7568    else 
76-       raise  TypeError ,  "unknown comment type: #{ comment . inspect }  " 
69+       comment  =  extract_comment ( comment ) 
70+       @comments  << comment  unless  comment . empty? 
7771    end 
7872  end 
7973
@@ -97,10 +91,6 @@ def aref
9791
9892  def  extract_comment  comment 
9993    case  comment 
100-     when  Array  then 
101-       comment . map  do  |c |
102-         extract_comment  c 
103-       end 
10494    when  nil 
10595      RDoc ::Comment . new  '' 
10696    when  RDoc ::Comment  then 
@@ -115,8 +105,6 @@ def extract_comment comment
115105                       end 
116106      end 
117107
118-       comment 
119-     when  RDoc ::Markup ::Document  then 
120108      comment 
121109    else 
122110      raise  TypeError ,  "unknown comment #{ comment . inspect }  " 
@@ -135,19 +123,8 @@ def hash # :nodoc:
135123  # The files comments in this section come from 
136124
137125  def  in_files 
138-     return  [ ]  if  @comments . empty? 
139- 
140-     case  @comments 
141-     when  Array  then 
142-       @comments . map  do  |comment |
143-         comment . file 
144-       end 
145-     when  RDoc ::Markup ::Document  then 
146-       @comment . parts . map  do  |document |
147-         document . file 
148-       end 
149-     else 
150-       raise  RDoc ::Error ,  "BUG: unknown comment class #{ @comments . class }  " 
126+     @comments . map  do  |comment |
127+       comment . file 
151128    end 
152129  end 
153130
@@ -170,34 +147,15 @@ def marshal_load array
170147    @parent   =  nil 
171148
172149    @title     =  array [ 1 ] 
173-     @comments  =  array [ 2 ] 
150+     @comments  =  array [ 2 ] . parts . map   {  | doc |  RDoc :: Comment . from_document ( doc )   } 
174151  end 
175152
176153  ## 
177154  # Parses +comment_location+ into an RDoc::Markup::Document composed of 
178155  # multiple RDoc::Markup::Documents with their file set. 
179156
180157  def  parse 
181-     case  @comments 
182-     when  String  then 
183-       super 
184-     when  Array  then 
185-       docs  =  @comments . map  do  |comment ,  location |
186-         doc  =  super  comment 
187-         doc . file  =  location  if  location 
188-         doc 
189-       end 
190- 
191-       RDoc ::Markup ::Document . new ( *docs ) 
192-     when  RDoc ::Comment  then 
193-       doc  =  super  @comments . text ,  comments . format 
194-       doc . file  =  @comments . location 
195-       doc 
196-     when  RDoc ::Markup ::Document  then 
197-       return  @comments 
198-     else 
199-       raise  ArgumentError ,  "unknown comment class #{ comments . class }  " 
200-     end 
158+     RDoc ::Markup ::Document . new ( *@comments . map ( &:parse ) ) 
201159  end 
202160
203161  ## 
@@ -214,19 +172,8 @@ def plain_html
214172  # +comment+ 
215173
216174  def  remove_comment  comment 
217-     return  if  @comments . empty? 
218- 
219-     case  @comments 
220-     when  Array  then 
221-       @comments . delete_if  do  |my_comment |
222-         my_comment . file  == comment . file 
223-       end 
224-     when  RDoc ::Markup ::Document  then 
225-       @comments . parts . delete_if  do  |document |
226-         document . file  == comment . file . name 
227-       end 
228-     else 
229-       raise  RDoc ::Error ,  "BUG: unknown comment class #{ @comments . class }  " 
175+     @comments . delete_if  do  |my_comment |
176+       my_comment . file  == comment . file 
230177    end 
231178  end 
232179
0 commit comments