Class: BaseTable

Inherits:
Object
  • Object
show all
Defined in:
lib/veye/views/base_table.rb

Instance Method Summary collapse

Constructor Details

#initialize(title, headings) ⇒ BaseTable

Returns a new instance of BaseTable.



4
5
6
7
# File 'lib/veye/views/base_table.rb', line 4

def initialize(title, headings)
  @title = title
  @headings = headings
end

Instance Method Details

#after(paging = nil, allow_pagination = false) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/veye/views/base_table.rb', line 16

def after(paging = nil, allow_pagination = false)
  if allow_pagination && !paging.nil?
    paging_header = ['p', 'current_page', 'per_page', 'total_pages', 'total_entries']
    paging_data = ["p"]
    paging.each_pair do |key, val|
      paging_data << val
    end

    @table.add_separator
    @table << paging_header
    @table << paging_data
  end
  puts @table.to_s
end

#beforeObject



9
10
11
12
13
14
# File 'lib/veye/views/base_table.rb', line 9

def before
  @table = Terminal::Table.new :title => @title,
                               :headings => @headings

  @table.align_column(0, :right)
end

#format(result) ⇒ Object

Raises:

  • (NotImplementedError)


31
32
33
# File 'lib/veye/views/base_table.rb', line 31

def format(result)
  raise NotImplementedError
end