Class: Pathways::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/pathways/filter.rb

Class Method Summary collapse

Class Method Details

.buildObject



35
36
37
# File 'lib/pathways/filter.rb', line 35

def self.build
  Pathways::Session.collection.map_reduce(map, reduce)
end

.mapObject



3
4
5
6
7
8
9
10
11
# File 'lib/pathways/filter.rb', line 3

def self.map
  "  function(){\n    this.visits.forEach(function(visit){\n      emit(visit.url, 1);\n    });\n  }\n  JS\nend\n"

.reduceObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pathways/filter.rb', line 13

def self.reduce
  "  function(prev, current) {\n    var count = 0;\n\n    for (index in current) {\n        count += current[index];\n    }\n\n    return count;\n  }\n  JS\nend\n"

.tag_cloud(opts = {}) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/pathways/filter.rb', line 27

def self.tag_cloud(opts={})
  opts.merge({
    :out    => {:inline => true},
    :raw    => true
  })
  self.build(opts).find()
end