Class: Step
Overview
This class represents one of the steps inside a history object. It will look something like the following:
"variables"=>[
{"id"=>3, "value"=>"Grim Fandang", "abs_id"=>-606538658, :uniq_id=>3,
"value"=>"Grim Fandango", "abs_id"=>-606538498, :uniq_id=>2
],
"line"=>1,
"statement_id"=>625,
"action"=>"var='Grim Fandango'.chop"}
Instance Method Summary collapse
- #cauldron_method_calls ⇒ Object
- #copy ⇒ Object
-
#find_data_for_variable(id) ⇒ Object
Returns the data for the variable thats id was specified.
-
#initialize(line, statement_id, variables, action) ⇒ Step
constructor
A new instance of Step.
- #to_var(id = nil, uniq_id = nil) ⇒ Object
Methods inherited from Hash
Constructor Details
#initialize(line, statement_id, variables, action) ⇒ Step
Returns a new instance of Step.
19 20 21 22 23 24 25 26 27 |
# File 'lib/core/tracking/Step.rb', line 19 def initialize(line,statement_id,variables,action) super() self['variables'] = variables self['line'] = line self['statement_id'] = statement_id # TODO action can proably be dropped - or just replaced with statement.write - I don't # think to_literal_string is useful. self['action'] = action end |
Instance Method Details
#cauldron_method_calls ⇒ Object
48 49 50 |
# File 'lib/core/tracking/Step.rb', line 48 def cauldron_method_calls return ["['statement_id']"] end |
#copy ⇒ Object
43 44 45 46 |
# File 'lib/core/tracking/Step.rb', line 43 def copy # TODO Don't use Marshal - do it properly return Marshal.load(Marshal.dump(self)) end |
#find_data_for_variable(id) ⇒ Object
Returns the data for the variable thats id was specified.
33 34 35 36 |
# File 'lib/core/tracking/Step.rb', line 33 def find_data_for_variable(id) missing_variable = lambda { raise StandardError.new('Couldn\'t find information on variable '+id.to_s) } return self['variables'].detect(missing_variable) {|x| x['id']==id} end |
#to_var(id = nil, uniq_id = nil) ⇒ Object
38 39 40 41 |
# File 'lib/core/tracking/Step.rb', line 38 def to_var(id=nil,uniq_id=nil) # TODO I don't know if the the block is used anymore return StepVariable.new(self,id) {{:variable_id => id,:uniq_id=>uniq_id}} end |