Class: Picky::Analytics

Inherits:
Object show all
Defined in:
lib/picky/analytics.rb

Overview

This class is wrapped around indexes and extracts useful information to be displayed in beoootiful, live-updating graphs.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*indexes) ⇒ Analytics

Returns a new instance of Analytics.



12
13
14
# File 'lib/picky/analytics.rb', line 12

def initialize *indexes
  @indexes = Indexes.new *indexes
end

Instance Attribute Details

#indexesObject (readonly)

Returns the value of attribute indexes.



10
11
12
# File 'lib/picky/analytics.rb', line 10

def indexes
  @indexes
end

Instance Method Details

#idsObject



26
27
28
29
30
31
32
# File 'lib/picky/analytics.rb', line 26

def ids
  total = 0
  indexes.each_bundle do |bundle|
    total += bundle.inverted.inject(0) { |total, (_, values)| total + values.size }
  end
  total
end

#tokensObject

Returns the number of tokens in all the inverted indexes.



18
19
20
21
22
23
24
# File 'lib/picky/analytics.rb', line 18

def tokens
  total = 0
  indexes.each_bundle do |bundle|
    total += bundle.inverted.size
  end
  total
end