class NodeTypeCounter
Count node types (:send, :lvar etc)
Attributes
node_types[R]
Public Class Methods
new(filename)
click to toggle source
# File lib/zombie_killer/node_type_counter.rb, line 11 def initialize(filename) @node_types = CodeHistogram.new @filename = filename end
Public Instance Methods
print(io)
click to toggle source
# File lib/zombie_killer/node_type_counter.rb, line 22 def print(io) parser = Parser::CurrentRuby.new buffer = Parser::Source::Buffer.new(@filename) buffer.read ast = parser.parse(buffer) process(ast) @node_types.print_by_frequency(io) end
process(node)
click to toggle source
Calls superclass method
# File lib/zombie_killer/node_type_counter.rb, line 16 def process(node) return if node.nil? @node_types.increment(node.type) super end