class CLIEditor

Constants

BadFormatError

Public Class Methods

new(cmd = 'vim') click to toggle source
# File lib/cli_editor.rb, line 6
def initialize(cmd = 'vim')
  @cmd = cmd
end

Public Instance Methods

edit(str) click to toggle source
# File lib/cli_editor.rb, line 9
def edit(str)
  tf = Tempfile.new
  tf.write str
  tf.close
  system @cmd, tf.path
  tf.open
  data = tf.read
  tf.close
  tf.unlink
  data
end