lib/pelusa/class_analyzer.rb in pelusa-0.2.2 vs lib/pelusa/class_analyzer.rb in pelusa-0.2.3
- old
+ new
@@ -12,17 +12,33 @@
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::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