Class: Cauldron::Histories
- Inherits:
-
Object
- Object
- Cauldron::Histories
- Defined in:
- lib/cauldron/histories.rb
Instance Method Summary collapse
- #contexts_at(point) ⇒ Object
- #each(&block) ⇒ Object
- #first ⇒ Object
-
#initialize(results) ⇒ Histories
constructor
A new instance of Histories.
- #insert_points ⇒ Object
- #length ⇒ Object
- #variable_permutations(count) ⇒ Object
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 |
#first ⇒ Object
26 27 28 |
# File 'lib/cauldron/histories.rb', line 26 def first @results.first end |
#insert_points ⇒ Object
34 35 36 |
# File 'lib/cauldron/histories.rb', line 34 def insert_points @results.inject([]) { |total, x| total += x.insert_points; total }.uniq end |
#length ⇒ Object
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 |