Class: DBA::RowEditor

Inherits:
Object
  • Object
show all
Defined in:
lib/dba/row_editor.rb

Instance Method Summary collapse

Constructor Details

#initialize(row_parser) ⇒ RowEditor

Returns a new instance of RowEditor.



4
5
6
7
8
# File 'lib/dba/row_editor.rb', line 4

def initialize(row_parser)
  @row_parser = row_parser

  @editor = ENV['EDITOR']
end

Instance Method Details

#edit(hash) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/dba/row_editor.rb', line 10

def edit(hash)
  io = IO.popen(@editor, 'w+')

  printer = DBA::Printer.new(io)
  printer.print_row(hash)

  io.close_write

  output = io.read

  io.close

  @row_parser.parse(output)
end