Sha256: a1a3931befab356bea9371c1938b45771d9c93ea8e7e1db40dfd7b982ef37d9a
Contents?: true
Size: 877 Bytes
Versions: 7
Compression:
Stored size: 877 Bytes
Contents
require 'private_attr/everywhere' module Reek # Represents functionality related to an Abstract Syntax Tree. module AST # Responsible for holding one specific object reference. ObjectRef = Struct.new(:name, :line) # # Manages and counts the references out of a method to other objects. # class ObjectRefs def initialize @refs = Hash.new { |refs, name| refs[name] = [] } end def most_popular max = refs.values.map(&:size).max refs.select { |_name, refs| refs.size == max } end def record_reference_to(name, line: nil) refs[name] << ObjectRef.new(name, line) end def references_to(name) refs[name] end def self_is_max? refs.empty? || most_popular.keys.include?(:self) end private private_attr_reader :refs end end end
Version data entries
7 entries across 7 versions & 1 rubygems