Class: Hashira::Analysis::Census
- Inherits:
-
Object
- Object
- Hashira::Analysis::Census
- Defined in:
- lib/hashira/analysis/census.rb
Instance Attribute Summary collapse
-
#declaring_package ⇒ Object
readonly
Returns the value of attribute declaring_package.
-
#root_namespace ⇒ Object
readonly
Returns the value of attribute root_namespace.
-
#type_count ⇒ Object
readonly
Returns the value of attribute type_count.
Instance Method Summary collapse
-
#initialize(project, trees) ⇒ Census
constructor
A new instance of Census.
- #packages ⇒ Object
- #resolve(segments) ⇒ Object
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) @declaring_package = {} @root_namespace = RootNamespace.infer(@definitions) take end |
Instance Attribute Details
#declaring_package ⇒ Object (readonly)
Returns the value of attribute declaring_package.
14 15 16 |
# File 'lib/hashira/analysis/census.rb', line 14 def declaring_package @declaring_package end |
#root_namespace ⇒ Object (readonly)
Returns the value of attribute root_namespace.
14 15 16 |
# File 'lib/hashira/analysis/census.rb', line 14 def root_namespace @root_namespace end |
#type_count ⇒ Object (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
#packages ⇒ Object
16 |
# File 'lib/hashira/analysis/census.rb', line 16 def packages = (@type_count.keys | @definitions.packages) |
#resolve(segments) ⇒ Object
18 19 20 21 |
# File 'lib/hashira/analysis/census.rb', line 18 def resolve(segments) outer, inner = segments.first(2) @declaring_package[outer == root_namespace ? inner : outer] end |