Module: Evoke::Comment

Included in:
Task
Defined in:
lib/evoke/comment.rb

Overview

Extendable module for extracting multi-line comments for a class at runtime.

Examples:

Reading the comment of a class.


# This is the multi-line
# comment that will be read.
class HelloWorld
  extend Evoke::Comment

  def a_method
    # this won't work without at least one non-inherited method
  end
end

HelloWorld.class_comment # => the multi-line comment before the class

Instance Method Summary collapse

Instance Method Details

#class_commentString

Note:

At least one non-inherited method needs to be present in the class.

Extracts the comment prefixing a class.



22
23
24
# File 'lib/evoke/comment.rb', line 22

def class_comment
  @class_comment ||= defined_methods.empty? ? '' : extract_class_comment
end