Class: MethodExtensions::MethodSourceWithDoc::MethodDocRipper

Inherits:
Ripper
  • Object
show all
Defined in:
lib/method_extensions/method/source_with_doc.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, method_definition_lineno) ⇒ MethodDocRipper

Returns a new instance of MethodDocRipper.



244
245
246
247
248
# File 'lib/method_extensions/method/source_with_doc.rb', line 244

def initialize(filename, method_definition_lineno)
  super(IO.read(filename), filename)
  @method_definition_lineno = method_definition_lineno
  @last_comment_block = nil
end

Class Method Details

.doc_from_source_location(source_location) ⇒ Object



239
240
241
242
# File 'lib/method_extensions/method/source_with_doc.rb', line 239

def self.doc_from_source_location(source_location)
  return unless source_location
  new(*source_location).method_doc
end

Instance Method Details

#method_docObject



250
251
252
253
# File 'lib/method_extensions/method/source_with_doc.rb', line 250

def method_doc
  parse
  @method_doc
end

#on_comment(token) ⇒ Object



266
267
268
# File 'lib/method_extensions/method/source_with_doc.rb', line 266

def on_comment(token)
  (@last_comment_block ||= []) << token
end

#on_sp(token) ⇒ Object



270
271
272
# File 'lib/method_extensions/method/source_with_doc.rb', line 270

def on_sp(token)
  @last_comment_block << token if @last_comment_block
end