Class: Reek::Source::CodeComment

Inherits:
Object
  • Object
show all
Defined in:
lib/reek/source/code_comment.rb

Overview

A comment header from an abstract syntax tree; found directly above module, class and method definitions.

Constant Summary collapse

CONFIG_REGEX =
/:reek:(\w+)(:\s*\{.*?\})?/

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ CodeComment

Returns a new instance of CodeComment


12
13
14
15
16
17
# File 'lib/reek/source/code_comment.rb', line 12

def initialize(text)
  @text = text.gsub(CONFIG_REGEX) do
    add_to_config($1, $2)
    ''
  end.gsub(/#/, '').gsub(/\n/, '').strip
end

Instance Method Details

#configObject


19
20
21
# File 'lib/reek/source/code_comment.rb', line 19

def config
  @config ||= Hash.new { |hash, key| hash[key] = {} }
end

#descriptive?Boolean

Returns:

  • (Boolean)

23
24
25
# File 'lib/reek/source/code_comment.rb', line 23

def descriptive?
  @text.split(/\s+/).length >= 2
end