Class: Pressy::Editor
- Inherits:
-
Object
- Object
- Pressy::Editor
- Defined in:
- lib/pressy/editor.rb
Instance Method Summary collapse
- #edit(post) ⇒ Object
-
#initialize(editor, console) ⇒ Editor
constructor
A new instance of Editor.
Constructor Details
#initialize(editor, console) ⇒ Editor
Returns a new instance of Editor
4 5 6 7 |
# File 'lib/pressy/editor.rb', line 4 def initialize(editor, console) @editor = editor @console = console end |
Instance Method Details
#edit(post) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pressy/editor.rb', line 9 def edit(post) rendered_post = Pressy::PostRenderer.render(post) content = Tempfile.create(['draft', '.md']) do |file| file.write rendered_post.content file.fsync @console.run("#{@editor} \"#{file.path}\"") File.read(file.path) end Pressy::PostParser.parse(format: post.format, content: content) end |