Class: CLIEditor
- Inherits:
-
Object
- Object
- CLIEditor
- Defined in:
- lib/cli_editor.rb
Constant Summary collapse
- BadFormatError =
Class.new StandardError
Instance Method Summary collapse
- #edit(str) ⇒ Object
-
#initialize(cmd = 'vim') ⇒ CLIEditor
constructor
A new instance of CLIEditor.
Constructor Details
#initialize(cmd = 'vim') ⇒ CLIEditor
Returns a new instance of CLIEditor.
6 7 8 |
# File 'lib/cli_editor.rb', line 6 def initialize(cmd = 'vim') @cmd = cmd end |
Instance Method Details
#edit(str) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# 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 |