Sha256: 7335d9ac6a6802db75fc3d14af4e459c92bb06f97213ff9f3b78edc7b5c28c8d

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

class Pelusa::ClassAnalyzer
  # Public: Initializes a ClassAnalyzer.
  #
  # klass - The class AST node.
  def initialize(klass)
    @klass = klass
  end

  # Public: Returns the name of the Class being analyzed.
  #
  # Returns the String name.
  def class_name
    name = @klass.name
    name.name
  end

  # Public: Returns the type of container being examined (class or module).
  def type
    @klass.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::Class) ? "class" : "module"
  end

  # Public: Analyzes a class with a series of lints.
  #
  # lints - The lints to check for.
  #
  # Returns a collection of Analysis, one for each lint.
  def analyze(lints)
    lints.map do |lint_class|
      lint = lint_class.new
      lint.check(@klass)
    end
  end

  # Public: Walk a node, analyzing it as it goes.
  #
  # block - supply a block that will be executed as the node gets walked.
  def self.walk(start_node)
    raise ArgumentError, "Walk requires a block!" unless block_given?
    start_node.walk do |continue, node|
      yield(node)
      true
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pelusa-0.2.4 lib/pelusa/class_analyzer.rb