Sha256: fc21998977b6a5c46c97b2d61cba41610d74fd60f1291051d396f71800324113
Contents?: true
Size: 549 Bytes
Versions: 1
Compression:
Stored size: 549 Bytes
Contents
require 'syntax_finder' class SingletonClassInDefFinder < SyntaxFinder # use traverse instead of look def traverse node, in_def = nil, in_sclass = nil if node.type == :class_node && in_sclass && node.constant_path.type != :constant_read_node pp [nloc(node), nlines(node).lines.first.chomp] end if node.type == :def_node in_def = true; in_sclass = false elsif node.type == :singleton_class_node && in_def in_sclass = true end node.child_nodes.compact.each{|n| traverse n, in_def, in_sclass} end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
syntax_finder-0.1.0 | samples/singleton_class_in_def_finder.rb |