Class: Hashira::Analysis::Census

Inherits:
Object
  • Object
show all
Defined in:
lib/hashira/analysis/census.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, trees) ⇒ Census

Returns a new instance of Census.



6
7
8
9
10
11
12
# File 'lib/hashira/analysis/census.rb', line 6

def initialize(project, trees)
  @definitions = Definitions.new(project, trees)
  @type_count = Hash.new(0)
  @registry = ConstantRegistry.new
  @namespace_prefix = NamespacePrefix.infer(@definitions)
  take
end

Instance Attribute Details

#namespace_prefixObject (readonly)

Returns the value of attribute namespace_prefix.



14
15
16
# File 'lib/hashira/analysis/census.rb', line 14

def namespace_prefix
  @namespace_prefix
end

#type_countObject (readonly)

Returns the value of attribute type_count.



14
15
16
# File 'lib/hashira/analysis/census.rb', line 14

def type_count
  @type_count
end

Instance Method Details

#declaring_packageObject



16
# File 'lib/hashira/analysis/census.rb', line 16

def declaring_package = @registry.declaring_package

#packagesObject



18
# File 'lib/hashira/analysis/census.rb', line 18

def packages = (@type_count.keys | @definitions.packages)

#resolve(segments) ⇒ Object



20
# File 'lib/hashira/analysis/census.rb', line 20

def resolve(segments) = @registry.package_for(after_prefix(segments))