Class: DiningTable::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/dining-table/table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection, view_context, options = {}) ⇒ Table

Returns a new instance of Table.



7
8
9
10
11
12
13
14
15
# File 'lib/dining-table/table.rb', line 7

def initialize( collection, view_context, options = {} )
  self.collection = collection
  self.view_context = view_context
  self.index     = 0
  self.columns   = [ ]
  self.options   = options
  initialize_presenter( options )
  define
end

Instance Attribute Details

#action_columnsObject

Returns the value of attribute action_columns.



5
6
7
# File 'lib/dining-table/table.rb', line 5

def action_columns
  @action_columns
end

#collectionObject

Returns the value of attribute collection.



5
6
7
# File 'lib/dining-table/table.rb', line 5

def collection
  @collection
end

#columnsObject

Returns the value of attribute columns.



5
6
7
# File 'lib/dining-table/table.rb', line 5

def columns
  @columns
end

#indexObject

Returns the value of attribute index.



5
6
7
# File 'lib/dining-table/table.rb', line 5

def index
  @index
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/dining-table/table.rb', line 5

def options
  @options
end

#presenterObject

Returns the value of attribute presenter.



5
6
7
# File 'lib/dining-table/table.rb', line 5

def presenter
  @presenter
end

#view_contextObject

Returns the value of attribute view_context.



5
6
7
# File 'lib/dining-table/table.rb', line 5

def view_context
  @view_context
end

Instance Method Details

#defineObject

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/dining-table/table.rb', line 17

def define
  raise NotImplementedError
end

#helpersObject Also known as: h



35
36
37
# File 'lib/dining-table/table.rb', line 35

def helpers
  view_context
end

#renderObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dining-table/table.rb', line 21

def render
  presenter.start_table
  presenter.render_header unless no_header
  presenter.start_body
  collection.each_with_index do |object, index_|
    self.index = index_
    presenter.render_row( object )
  end
  presenter.end_body
  presenter.render_footer
  presenter.end_table
  presenter.output
end