Class: TableList

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

Instance Method Summary collapse

Constructor Details

#initialize(instance) ⇒ TableList

Returns a new instance of TableList.



2
3
4
# File 'lib/table_list.rb', line 2

def initialize(instance)
  @instance = instance
end

Instance Method Details

#headers(columns = [], widths = {}) ⇒ Object



12
13
14
15
16
# File 'lib/table_list.rb', line 12

def headers(columns=[], widths={})
  @instance. :tr do
    @instance.concat(@instance.get_table_headers(columns, widths))
  end
end

#sortable_headers(columns = [], widths = {}) ⇒ Object



6
7
8
9
10
# File 'lib/table_list.rb', line 6

def sortable_headers(columns=[], widths={})
  @instance. :tr do
    @instance.concat(@instance.get_sortable_table_headers(columns, widths))  
  end
end

#td(data, options = {}) ⇒ Object



18
19
20
# File 'lib/table_list.rb', line 18

def td(data, options={})
  @instance. :td, data.to_s.html_safe, :class => options[:class]# unless options[:class].blank?
end

#tr(&block) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/table_list.rb', line 22

def tr(&block)
  raise "need a block" unless block_given?

  result = @instance.capture do
    @instance. :tr do
      block.call(self) 
    end
  end 
end