Class: Compendium::Presenters::Table
- Defined in:
- app/classes/compendium/presenters/table.rb
Instance Attribute Summary collapse
-
#records ⇒ Object
readonly
Returns the value of attribute records.
-
#totals ⇒ Object
readonly
Returns the value of attribute totals.
Instance Method Summary collapse
-
#initialize {|@settings| ... } ⇒ Table
constructor
A new instance of Table.
- #render ⇒ Object
Methods inherited from Base
Constructor Details
#initialize {|@settings| ... } ⇒ Table
Returns a new instance of Table.
5 6 7 8 9 10 11 12 13 |
# File 'app/classes/compendium/presenters/table.rb', line 5 def initialize(*) super @records = results.records @totals = @records.pop if has_totals_row? @settings = settings_class.new(results.keys) yield @settings if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Compendium::Presenters::Base
Instance Attribute Details
#records ⇒ Object (readonly)
Returns the value of attribute records.
3 4 5 |
# File 'app/classes/compendium/presenters/table.rb', line 3 def records @records end |
#totals ⇒ Object (readonly)
Returns the value of attribute totals.
3 4 5 |
# File 'app/classes/compendium/presenters/table.rb', line 3 def totals @totals end |
Instance Method Details
#render ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/classes/compendium/presenters/table.rb', line 15 def render content_tag(:table, class: 'results') do table = ActiveSupport::SafeBuffer.new table << content_tag(:thead, build_heading_row) table << content_tag(:tbody) do tbody = ActiveSupport::SafeBuffer.new records.each { |row| tbody << build_data_row(row) } tbody end table << content_tag(:tfoot, build_totals_row) if has_totals_row? table end end |