Sha256: a23b8e7857ab90df0dfcee89f85b11d20b0c9b03d624bb2f9a9f2a05d63b07af

Contents?: true

Size: 960 Bytes

Versions: 18

Compression:

Stored size: 960 Bytes

Contents

module Redcar
  class REPL
    module ReplMirror
      include Redcar::Document::Mirror
  
      # Execute a new statement. Accepts the entire pretty formatted history,
      # within which it looks for the last statement and executes it.
      #
      # @param [String] a string with at least one prompt and statement in it
      def commit(contents)
        if contents.split("\n").last =~ /#{@prompt}\s+$/
          command = ""
        else
          command = contents.split(@prompt).last.strip
        end
        send_to_repl command
      end

      # REPLs always exist because there is no external resource to represent.
      def exists?
        true
      end

      # REPLs never change except for after commit operations.
      def changed?
        false
      end
      
      private
      
      # Language-specific method for evaluating statements
      def send_to_repl expr
        raise "not implemented"
      end
      
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
redcar-0.7 plugins/repl/lib/repl/repl_mirror.rb
redcar-0.6.1 plugins/repl/lib/repl/repl_mirror.rb
redcar-0.6 plugins/repl/lib/repl/repl_mirror.rb
redcar-0.6.1dev plugins/repl/lib/repl/repl_mirror.rb
redcar-0.5.1 plugins/repl/lib/repl/repl_mirror.rb
redcar-0.5 plugins/repl/lib/repl/repl_mirror.rb
redcar-0.5.6dev plugins/repl/lib/repl/repl_mirror.rb
redcar-0.5.5dev plugins/repl/lib/repl/repl_mirror.rb
redcar-0.5.4dev plugins/repl/lib/repl/repl_mirror.rb
redcar-0.5.3dev plugins/repl/lib/repl/repl_mirror.rb
redcar-0.5.2dev plugins/repl/lib/repl/repl_mirror.rb
redcar-0.5.1dev plugins/repl/lib/repl/repl_mirror.rb
redcar-0.4.1 plugins/repl/lib/repl/repl_mirror.rb
redcar-0.4 plugins/repl/lib/repl/repl_mirror.rb
redcar-0.3.10.1dev plugins/repl/lib/repl/repl_mirror.rb
redcar-0.3.10.0dev plugins/repl/lib/repl/repl_mirror.rb
redcar-0.3.9 plugins/repl/lib/repl/repl_mirror.rb
redcar-0.3.9.0dev plugins/repl/lib/repl/repl_mirror.rb