lib/interpreter/interpreter.rb in nudge-0.1.2 vs lib/interpreter/interpreter.rb in nudge-0.1.3
- old
+ new
@@ -18,12 +18,12 @@
attr_accessor :last_name, :evaluate_references
attr_accessor :sensors
# A program to be interpreted can be passed in as an optional parameter
- def initialize(params = {})
- initialProgram = params[:program] || nil
+ def initialize(program = nil, params = {})
+ initialProgram = program
@program = initialProgram
@types = params[:types] || NudgeType.all_types
@step_limit = params[:step_limit] || 3000
@sensors = Hash.new
@@ -55,10 +55,10 @@
def reset(program=nil)
@program = program
self.clear_stacks
self.reset_names
self.reset_sensors
- if program
+ if !program.nil?
@stacks[:exec].push(NudgeProgram.new(program).linked_code)
end
@steps = 0
@evaluate_references = true
end
\ No newline at end of file