Module: Cursorable

Included in:
LiveSQL
Defined in:
lib/live_sql/cursorable.rb

Instance Method Summary collapse

Instance Method Details

#backspaceObject



19
20
21
22
23
24
25
# File 'lib/live_sql/cursorable.rb', line 19

def backspace
  if @string.length > 1
    @string.slice!(@cursor_pos - 1)
    @cursor_pos -= 1 unless @cursor_pos == 0
  end
  attempt_to_query_db
end

#deleteObject



27
28
29
30
31
32
# File 'lib/live_sql/cursorable.rb', line 27

def delete
  if @string.length > 1
    @string.slice!(@cursor_pos)
  end
  attempt_to_query_db
end

#errorObject



3
4
# File 'lib/live_sql/cursorable.rb', line 3

def error
end

#leftObject



11
12
13
# File 'lib/live_sql/cursorable.rb', line 11

def left
  @cursor_pos -= 1 unless @cursor_pos == 0
end

#quitObject



6
7
8
9
# File 'lib/live_sql/cursorable.rb', line 6

def quit
  system("clear")
  abort
end

#rightObject



15
16
17
# File 'lib/live_sql/cursorable.rb', line 15

def right
  @cursor_pos += 1 unless @cursor_pos == @string.length - 1
end