Module: Qtrix::Matrix::Analyzer
- Defined in:
- lib/qtrix/matrix/analyzer.rb
Overview
Utility class to examining the distribution of queues within a matrix. Its operations result in a hash of queue names mapped to arrays containing counts that the queue appeared in that column index of the matrix.
Class Method Summary collapse
-
.analyze!(rows, queue_weights = {}) ⇒ Object
Maps the specified queue weights, generates a matrix with the specified number of rows, then breaks it down as above.
-
.breakdown(matrix) ⇒ Object
Breaks down any old matrix.
Class Method Details
.analyze!(rows, queue_weights = {}) ⇒ Object
Maps the specified queue weights, generates a matrix with the specified number of rows, then breaks it down as above.
32 33 34 35 36 37 38 |
# File 'lib/qtrix/matrix/analyzer.rb', line 32 def self.analyze!(rows, queue_weights={}) Qtrix::Matrix.clear! Qtrix::Queue.clear! Qtrix::Queue.map_queue_weights(queue_weights) Qtrix::Matrix.queues_for!(`hostname`, rows) breakdown(Qtrix::Matrix.to_table) end |
.breakdown(matrix) ⇒ Object
Breaks down any old matrix
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/qtrix/matrix/analyzer.rb', line 10 def self.breakdown(matrix) result_hash_for(matrix).tap do |result| matrix.each do |row| row.each_with_index do |queue, column| result[queue][column] += 1 end end def result.to_s self.map{|queue, pos| "#{queue}: #{pos.join(',')}"}.join("\n") end def result.dump puts self end end end |