Class: Cauldron::Histories

Inherits:
Object
  • Object
show all
Defined in:
lib/cauldron/histories.rb

Instance Method Summary collapse

Constructor Details

#initialize(results) ⇒ Histories

Returns a new instance of Histories.



5
6
7
# File 'lib/cauldron/histories.rb', line 5

def initialize(results)
  @results = results
end

Instance Method Details

#contexts_at(point) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/cauldron/histories.rb', line 38

def contexts_at(point)
  a = []
  @results.each do |history|
    a += history.logs.inject([]) do |total,log|
      if log[:point] == point
        total << log
      end
      total
    end        
  end
  a
end

#each(&block) ⇒ Object



22
23
24
# File 'lib/cauldron/histories.rb', line 22

def each(&block)
  @results.each(&block)
end

#firstObject



26
27
28
# File 'lib/cauldron/histories.rb', line 26

def first
  @results.first
end

#insert_pointsObject



34
35
36
# File 'lib/cauldron/histories.rb', line 34

def insert_points
  @results.inject([]) { |total, x| total += x.insert_points; total }.uniq
end

#lengthObject



30
31
32
# File 'lib/cauldron/histories.rb', line 30

def length
  @results.length
end

#variable_permutations(count) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/cauldron/histories.rb', line 9

def variable_permutations(count)
  variables = @results.first.logs.first.keys.select { |x| x.match /var/ }
  v = Hash[*variables.collect {|x| [x,nil]}.flatten]

  @results.collect do |history|
    history.logs.collect do |a|
      Hash[*v.keys.collect do |x| 
        [x, a[x] ] 
      end.flatten(1)]
    end
  end.flatten      
end