Sha256: 11b7be5006610ae50f4bbd7cf03367c84547a6a8c262c0ea727af84f9573d3d8

Contents?: true

Size: 679 Bytes

Versions: 1

Compression:

Stored size: 679 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)
        with_evaluated_argument_in(context) do |result|
          context.head.take_out result
        end
      rescue RuntimeError => e
        raise Gobstones::Runner::GobstonesTypeError, e.message
      end

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

      def opposite
        Poner.new argument
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gobstones-0.0.2 lib/gobstones/lang/commands/sacar_cmd.rb