class Pry::Editor - pry-0.10.1 Documentation

# class Pry::Editor

### Attributes

_pry_[R]

### Public Class Methods

new(_pry_) click to toggle source

    # File lib/pry/editor.rb, line 8
    def initialize(_pry_)
      @_pry_ = _pry_
    end

### Public Instance Methods

edit_tempfile_with_content(initial_content, line=1) click to toggle source

    # File lib/pry/editor.rb, line 12
    def edit_tempfile_with_content(initial_content, line=1)
      temp_file do |f|
        f.puts(initial_content)
        f.flush
        f.close(false)
        invoke_editor(f.path, line, true)
        File.read(f.path)
      end
    end

invoke_editor(file, line, blocking=true) click to toggle source

    # File lib/pry/editor.rb, line 22
    def invoke_editor(file, line, blocking=true)
      raise CommandError, "Please set Pry.config.editor or export $VISUAL or $EDITOR" unless _pry_.config.editor

      editor_invocation = build_editor_invocation_string(file, line, blocking)
      return nil unless editor_invocation

      if jruby?
        open_editor_on_jruby(editor_invocation)
      else
        open_editor(editor_invocation)
      end
    end