Class: RenderTable::Base

Inherits:
Object
  • Object
show all
Includes:
ERB::Util
Defined in:
lib/render_table/base.rb

Direct Known Subclasses

Table

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Base

Returns a new instance of Base.



14
15
16
17
18
19
20
21
22
# File 'lib/render_table/base.rb', line 14

def initialize(args = {})
  @records     = args[:records]     || []
  @header      = args[:header]      || []
  @override    = args[:override]    || {}
  @table_id    = args[:table_id]    || RenderTable.config.table_id
  @table_class = args[:table_class] || RenderTable.config.table_class
  @html        = args[:html]        || RenderTable.config.html
  @options     = args[:options]
end

Instance Attribute Details

#headerObject

Returns the value of attribute header.



6
7
8
# File 'lib/render_table/base.rb', line 6

def header
  @header
end

#htmlObject

Returns the value of attribute html.



6
7
8
# File 'lib/render_table/base.rb', line 6

def html
  @html
end

#optionsObject

Returns the value of attribute options.



6
7
8
# File 'lib/render_table/base.rb', line 6

def options
  @options
end

#overrideObject

Returns the value of attribute override.



6
7
8
# File 'lib/render_table/base.rb', line 6

def override
  @override
end

#recordsObject

Returns the value of attribute records.



6
7
8
# File 'lib/render_table/base.rb', line 6

def records
  @records
end

#table_classObject

Returns the value of attribute table_class.



6
7
8
# File 'lib/render_table/base.rb', line 6

def table_class
  @table_class
end

#table_idObject

Returns the value of attribute table_id.



6
7
8
# File 'lib/render_table/base.rb', line 6

def table_id
  @table_id
end

Class Method Details

.render(args = {}) {|table| ... } ⇒ Object

Yields:

  • (table)


8
9
10
11
12
# File 'lib/render_table/base.rb', line 8

def self.render(args = {})
  table = new(args)
  yield table
  table.render
end

Instance Method Details

#contextObject



32
33
34
# File 'lib/render_table/base.rb', line 32

def context
  binding
end

#renderObject



28
29
30
# File 'lib/render_table/base.rb', line 28

def render
  ERB.new(template, 0, '%<>').result(binding)
end

#rowsObject



24
25
26
# File 'lib/render_table/base.rb', line 24

def rows
  RenderTable::Row.rows_for_table(self)
end