Class: QueryOutput

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

Instance Method Summary collapse

Constructor Details

#initialize(connection, query) ⇒ QueryOutput



3
4
5
6
# File 'lib/query_output.rb', line 3

def initialize(connection, query)
  @connection = connection
  @query = query
end

Instance Method Details

#showObject



8
9
10
11
# File 'lib/query_output.rb', line 8

def show
  exec 
  @connection.error? ? print_error : print_tables
end

#show_text_or_tableObject



13
14
15
16
17
18
19
20
21
# File 'lib/query_output.rb', line 13

def show_text_or_table
  exec 
  if @connection.one_column_one_row?
    print_text
  else
    print_tables unless @connection.error?
  end
  print_error if @connection.error?
end