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
  <<-JS
  function(){
    this.visits.forEach(function(visit){
      emit(visit.url, 1);
    });
  }
  JS
end

.reduceObject



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

def self.reduce
  <<-JS
  function(prev, current) {
    var count = 0;

    for (index in current) {
        count += current[index];
    }

    return count;
  }
  JS
end

.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