Class: RubyLens::Model::DependencyAggregation
- Inherits:
-
Object
- Object
- RubyLens::Model::DependencyAggregation
- Defined in:
- lib/rubylens/model/dependency_aggregation.rb
Constant Summary collapse
- SIGNAL_COLUMNS =
(1..6).freeze
Instance Method Summary collapse
- #add(package_index:, row:, construct_index:) ⇒ Object
-
#initialize(package_count:) ⇒ DependencyAggregation
constructor
A new instance of DependencyAggregation.
- #packages ⇒ Object
- #signal_maxima ⇒ Object
Constructor Details
#initialize(package_count:) ⇒ DependencyAggregation
Returns a new instance of DependencyAggregation.
8 9 10 11 12 13 14 15 |
# File 'lib/rubylens/model/dependency_aggregation.rb', line 8 def initialize(package_count:) raise ArgumentError, "package_count must be nonnegative" if package_count.negative? @counts = Array.new(package_count, 0) @ruby_counts = Array.new(package_count) { Array.new(4, 0) } @signal_maxima = Array.new(6, 0) @rows = Array.new(package_count) { [] } end |
Instance Method Details
#add(package_index:, row:, construct_index:) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/rubylens/model/dependency_aggregation.rb', line 17 def add(package_index:, row:, construct_index:) @counts[package_index] += 1 @ruby_counts[package_index][construct_index] += 1 if construct_index SIGNAL_COLUMNS.each_with_index do |column, index| @signal_maxima[index] = [@signal_maxima[index], row[column]].max end @rows[package_index] << row.dup.freeze end |
#packages ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/rubylens/model/dependency_aggregation.rb', line 26 def packages @counts.each_index.map do |index| { declaration_count: @counts[index], ruby_counts: @ruby_counts[index].dup.freeze, declarations: @rows[index].dup.freeze, }.freeze end.freeze end |
#signal_maxima ⇒ Object
36 37 38 |
# File 'lib/rubylens/model/dependency_aggregation.rb', line 36 def signal_maxima @signal_maxima.dup.freeze end |