Module: Cols::ClassMethods

Defined in:
lib/active_console/cols.rb

Instance Method Summary collapse

Instance Method Details

#cols(list = "") ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/active_console/cols.rb', line 5

def cols(list = "")

  matching_cols = ActiveConsole::ActiveConsoleArray.new
  searching_cols = list.split(",")

  columns.each do |col|
    if searching_cols.count > 0
      searching_cols.select do |c|
        matching_cols << ActiveConsole::ActiveConsoleHash[col.name, col.sql_type] if col.name.match(/^#{c.strip}/)
      end
    else
      matching_cols << ActiveConsole::ActiveConsoleHash[col.name, col.sql_type]
    end
  end
  matching_cols
end