class ClosingComments::Commentable

Public Class Methods

new(node) click to toggle source
# File lib/closing_comments/commentable.rb, line 11
def initialize(node)
  @node = node
end

Public Instance Methods

ending() click to toggle source
# File lib/closing_comments/commentable.rb, line 23
def ending
  "end # #{entity} #{name}"
end
name() click to toggle source
# File lib/closing_comments/commentable.rb, line 15
def name
  @name ||= name!(children.first)
end
single_line?() click to toggle source
# File lib/closing_comments/commentable.rb, line 19
def single_line?
  first_line == last_line
end

Private Instance Methods

name!(node) click to toggle source

This method reeks of :reek:FeatureEnvy and :reek:TooManyStatements.

# File lib/closing_comments/commentable.rb, line 30
def name!(node)
  return node unless node.is_a?(Parser::AST::Node)
  type = node.type
  return '' if type == :cbase
  first, second = node.children
  if type == :str
    loc = node.loc
    # Preserve quote formatting, some folks may prefer double quotes.
    return "#{loc.begin.source}#{first}#{loc.end.source}"
  end
  first ? [name!(first), second].join('::') : second
end