Sha256: 0b86883e9c272e860d7db46e2e88b287e30055123dcd954e7a8c85ca3cc7f953

Contents?: true

Size: 595 Bytes

Versions: 1

Compression:

Stored size: 595 Bytes

Contents

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

module Gobstones

  module Lang

    class Sacar < OneArgExpression

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

      def undo(context)
        context.head.put arg.evaluate(context)
      end

      def opposite
        Poner.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/sacar_cmd.rb