Class: DiningTable::Table
- Inherits:
-
Object
- Object
- DiningTable::Table
- Defined in:
- lib/dining-table/table.rb
Instance Attribute Summary collapse
-
#action_columns ⇒ Object
Returns the value of attribute action_columns.
-
#collection ⇒ Object
Returns the value of attribute collection.
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#index ⇒ Object
Returns the value of attribute index.
-
#options ⇒ Object
Returns the value of attribute options.
-
#presenter ⇒ Object
Returns the value of attribute presenter.
-
#view_context ⇒ Object
Returns the value of attribute view_context.
Instance Method Summary collapse
- #define ⇒ Object
- #helpers ⇒ Object (also: #h)
-
#initialize(collection, view_context, options = {}) ⇒ Table
constructor
A new instance of Table.
- #object_class ⇒ Object
- #render ⇒ Object
- #skip_footer ⇒ Object
- #skip_header ⇒ Object
Constructor Details
#initialize(collection, view_context, options = {}) ⇒ Table
Returns a new instance of Table.
10 11 12 13 14 15 16 17 18 |
# File 'lib/dining-table/table.rb', line 10 def initialize( collection, view_context, = {} ) self.collection = collection self.view_context = view_context self.index = 0 self.columns = [ ] self. = initialize_presenter( ) define end |
Instance Attribute Details
#action_columns ⇒ Object
Returns the value of attribute action_columns.
5 6 7 |
# File 'lib/dining-table/table.rb', line 5 def action_columns @action_columns end |
#collection ⇒ Object
Returns the value of attribute collection.
5 6 7 |
# File 'lib/dining-table/table.rb', line 5 def collection @collection end |
#columns ⇒ Object
Returns the value of attribute columns.
5 6 7 |
# File 'lib/dining-table/table.rb', line 5 def columns @columns end |
#index ⇒ Object
Returns the value of attribute index.
5 6 7 |
# File 'lib/dining-table/table.rb', line 5 def index @index end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/dining-table/table.rb', line 5 def @options end |
#presenter ⇒ Object
Returns the value of attribute presenter.
5 6 7 |
# File 'lib/dining-table/table.rb', line 5 def presenter @presenter end |
#view_context ⇒ Object
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
#define ⇒ Object
20 21 22 |
# File 'lib/dining-table/table.rb', line 20 def define raise NotImplementedError end |
#helpers ⇒ Object Also known as: h
38 39 40 |
# File 'lib/dining-table/table.rb', line 38 def helpers view_context end |
#object_class ⇒ Object
51 52 53 |
# File 'lib/dining-table/table.rb', line 51 def object_class [:class] end |
#render ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/dining-table/table.rb', line 24 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. unless presenter.end_table presenter.output end |
#skip_footer ⇒ Object
47 48 49 |
# File 'lib/dining-table/table.rb', line 47 def self. = true end |
#skip_header ⇒ Object
43 44 45 |
# File 'lib/dining-table/table.rb', line 43 def skip_header self.no_header = true end |