class Cauldron::Histories

Public Class Methods

new(results) click to toggle source
# File lib/cauldron/histories.rb, line 5
def initialize(results)
  @results = results
end

Public Instance Methods

contexts_at(point) click to toggle source
# 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) click to toggle source
# File lib/cauldron/histories.rb, line 22
def each(&block)
  @results.each(&block)
end
first() click to toggle source
# File lib/cauldron/histories.rb, line 26
def first
  @results.first
end
insert_points() click to toggle source
# File lib/cauldron/histories.rb, line 34
def insert_points
  @results.inject([]) { |total, x| total += x.insert_points; total }.uniq
end
length() click to toggle source
# File lib/cauldron/histories.rb, line 30
def length
  @results.length
end
variable_permutations(count) click to toggle source
# 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