Class: GHI::Editor
- Inherits:
-
Object
- Object
- GHI::Editor
- Defined in:
- lib/ghi/editor.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
- #gets(prefill) ⇒ Object
-
#initialize(filename) ⇒ Editor
constructor
A new instance of Editor.
- #unlink(message = nil) ⇒ Object
Constructor Details
#initialize(filename) ⇒ Editor
Returns a new instance of Editor.
6 7 8 |
# File 'lib/ghi/editor.rb', line 6 def initialize filename @filename = filename end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
5 6 7 |
# File 'lib/ghi/editor.rb', line 5 def filename @filename end |
Instance Method Details
#gets(prefill) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/ghi/editor.rb', line 10 def gets prefill File.open path, 'a+' do |f| f << prefill if File.zero? path f.rewind system "#{editor} #{f.path}" return File.read(f.path).gsub(/(?:^#.*$\n?)+\s*\z/, '').strip end end |
#unlink(message = nil) ⇒ Object
19 20 21 22 |
# File 'lib/ghi/editor.rb', line 19 def unlink = nil File.delete path abort if end |