Class: Gobstones::Lang::Commands::Sacar

Inherits:
OneArgExpression show all
Defined in:
lib/gobstones/lang/commands/sacar.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



9
10
11
12
13
14
15
# File 'lib/gobstones/lang/commands/sacar.rb', line 9

def evaluate(context)
  with_evaluated_argument_in(context) do |result|
    context.head.take_out result
  end
rescue RuntimeError => e
  raise Runner::GobstonesTypeError, e.message
end

#oppositeObject



23
24
25
# File 'lib/gobstones/lang/commands/sacar.rb', line 23

def opposite
  Poner.new(argument)
end

#undo(context) ⇒ Object



17
18
19
20
21
# File 'lib/gobstones/lang/commands/sacar.rb', line 17

def undo(context)
  with_evaluated_argument_in(context) do |result|
    context.head.put result
  end
end