Sha256: ad36ca39098a418eb438774bc82c5a0631f04e860204d577d421f0f53682e3ee

Contents?: true

Size: 681 Bytes

Versions: 1

Compression:

Stored size: 681 Bytes

Contents

require 'gobstones/lang/expressions/one_arg_expression'
require 'gobstones/lang/commands/sacar_cmd'
require 'gobstones/runner/errors/gobstones_type_error'

module Gobstones

  module Lang

    class Poner < OneArgExpression

      def evaluate(context)
        context.head.put arg.evaluate(context)
      rescue RuntimeError => e
        raise Gobstones::Runner::GobstonesTypeError, e.message
      end

      def undo(context)
        # TODO maybe the command should use the original context
        # instead of this one (when it was executed)
        context.head.take_out arg.evaluate(context)
      end

      def opposite
        Sacar.new arg
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gobstones-0.0.1.1 lib/gobstones/lang/commands/poner_cmd.rb