Class: Springpad::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/springpad/cli.rb

Instance Method Summary collapse

Instance Method Details

#editObject

Public: Edits a file with $EDITOR and returns the contents.

Returns an Array with the first line and an array of the other lines.



8
9
10
11
12
13
# File 'lib/springpad/cli.rb', line 8

def edit
  temp_file = Tempfile.new('block')
  system("$EDITOR #{temp_file.path}")
  contents = temp_file.read.chomp.split("\n").reject(&:empty?).map(&:strip)
  [contents.first, contents[1..-1]]
end