This library provides an easy way to extract comments from a ruby source file.
$ gem install getcomments
Or with bundler:
gem 'getcomments'
require 'getcomments'
comments = GetComments::Read.from 'filename.rb'
p comments
# => {
# "module TestModule" => "This is the module comment",
# "class TestClass" => "This is the class comment",
# "def some_method" => "This is a multiline\nmethod comment"
# }