Module: SQLite3::Query::Description

Defined in:
lib/sqlite3/query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#columnsObject

Returns the value of attribute columns.



57
58
59
# File 'lib/sqlite3/query.rb', line 57

def columns
  @columns
end

Instance Method Details

#data_tableObject

A Google Chart compatible data table; see developers.google.com/chart/interactive/docs/reference#dataparam



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/sqlite3/query.rb', line 61

def data_table
  cols = columns.map do |column|
    type = case column
    when /_at$/   then :datetime
    when /_on$/   then :date
    when /value/  then :number
    else               :string
    end

    { id: column, type: type, label: column }
  end

  rows = map { |record| convert_record record, cols }

  { cols: cols, rows: rows }
end