Class: Gobstones::Lang::Commands::Mover

Inherits:
OneArgExpression show all
Defined in:
lib/gobstones/lang/commands/mover.rb

Instance Attribute Summary

Attributes inherited from OneArgExpression

#argument

Instance Method Summary collapse

Methods inherited from OneArgExpression

#equality_attributes, #initialize, #with_evaluated_argument_in

Methods inherited from Expression

#is_function_call?

Methods included from EqualityDefinition

#==, #equality_attributes

Constructor Details

This class inherits a constructor from Gobstones::Lang::OneArgExpression

Instance Method Details

#evaluate(context) ⇒ Object



7
8
9
10
11
# File 'lib/gobstones/lang/commands/mover.rb', line 7

def evaluate(context)
  with_evaluated_argument_in(context) do |result|
    context.head.move result
  end
end

#oppositeObject



17
18
19
# File 'lib/gobstones/lang/commands/mover.rb', line 17

def opposite
  Mover.new(argument.opposite)
end

#undo(context) ⇒ Object



13
14
15
# File 'lib/gobstones/lang/commands/mover.rb', line 13

def undo(context)
  opposite.evaluate context
end