Class: DiscourseCli::Editor
- Inherits:
-
Object
- Object
- DiscourseCli::Editor
- Defined in:
- lib/discourse_cli/editor.rb
Instance Method Summary collapse
-
#initialize(spawn: nil) ⇒ Editor
constructor
A new instance of Editor.
- #open(initial_content = "") ⇒ Object
Constructor Details
#initialize(spawn: nil) ⇒ Editor
Returns a new instance of Editor.
8 9 10 |
# File 'lib/discourse_cli/editor.rb', line 8 def initialize(spawn: nil) @spawn = spawn || method(:default_spawn) end |
Instance Method Details
#open(initial_content = "") ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/discourse_cli/editor.rb', line 12 def open(initial_content = "") Tempfile.create(["dsc", ".md"]) do |f| f.write(initial_content) f.flush @spawn.call(f.path) f.rewind f.read end end |