Class: Cauldron::History

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logs) ⇒ History

Returns a new instance of History.



7
8
9
# File 'lib/cauldron/history.rb', line 7

def initialize(logs)
  @logs = logs
end

Instance Attribute Details

#logsObject (readonly)

Returns the value of attribute logs.



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

def logs
  @logs
end

Instance Method Details

#insert_pointsObject



28
29
30
# File 'lib/cauldron/history.rb', line 28

def insert_points
  logs.collect {|x| x[:point] }.uniq
end

#values(variable_name) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/cauldron/history.rb', line 19

def values(variable_name)
  @logs.inject([]) do |total,line|
    if line.has_key?(variable_name)
      total << line[variable_name]
    end
    total
  end
end

#variablesObject



11
12
13
14
15
16
17
# File 'lib/cauldron/history.rb', line 11

def variables
  results = []
  @logs.select do |line|
    results += line.keys.select {|x| x.match(/var*/) }
  end
  results
end