Class: HtmlTables::YieldedObject
- Inherits:
-
Object
- Object
- HtmlTables::YieldedObject
- Defined in:
- lib/html_tables/yielded_object.rb
Instance Attribute Summary collapse
-
#t ⇒ Object
readonly
Returns the value of attribute t.
Instance Method Summary collapse
-
#checkbox(id = nil, options = { }, &block) ⇒ Object
Adds a checkbox column to the DataTable.
-
#column(id, options = {}, &block) ⇒ Object
Adds a regular column to the DataTable.
- #group_by(column_or_lambda, &block) ⇒ Object
-
#initialize(data_table) ⇒ YieldedObject
constructor
A new instance of YieldedObject.
- #item_url(enabled = true, &block) ⇒ Object
-
#nodata(msg) ⇒ Object
Sets the ‘no-data’ message.
-
#radio(id = nil, options = { }) ⇒ Object
Adds a radio button column to the DataTable.
- #row_class(cls, options = { }) ⇒ Object
Constructor Details
#initialize(data_table) ⇒ YieldedObject
Returns a new instance of YieldedObject.
7 8 9 |
# File 'lib/html_tables/yielded_object.rb', line 7 def initialize(data_table) @t = data_table end |
Instance Attribute Details
#t ⇒ Object (readonly)
Returns the value of attribute t.
5 6 7 |
# File 'lib/html_tables/yielded_object.rb', line 5 def t @t end |
Instance Method Details
#checkbox(id = nil, options = { }, &block) ⇒ Object
Adds a checkbox column to the DataTable. If a block is supplied, it is used to determine the initial state of the checkbox.
17 18 19 20 |
# File 'lib/html_tables/yielded_object.rb', line 17 def checkbox(id = nil, = { }, &block) [:block] = block if block_given? t.columns[id] = .reverse_merge! checkbox: true, align: :center end |
#column(id, options = {}, &block) ⇒ Object
Adds a regular column to the DataTable.
30 31 32 33 34 |
# File 'lib/html_tables/yielded_object.rb', line 30 def column(id, = {}, &block) [:block] = block if block_given? t.columns[id] = nil end |
#group_by(column_or_lambda, &block) ⇒ Object
36 37 38 39 |
# File 'lib/html_tables/yielded_object.rb', line 36 def group_by(column_or_lambda, &block) t.group_by column_or_lambda, &block self end |
#item_url(enabled = true, &block) ⇒ Object
47 48 49 50 |
# File 'lib/html_tables/yielded_object.rb', line 47 def item_url(enabled = true, &block) t. = { :block => block, :enabled => enabled } nil end |
#nodata(msg) ⇒ Object
Sets the ‘no-data’ message. If not set, no message will be displayed when there’s no records to show.
42 43 44 45 |
# File 'lib/html_tables/yielded_object.rb', line 42 def nodata(msg) t. = msg nil end |
#radio(id = nil, options = { }) ⇒ Object
Adds a radio button column to the DataTable.
25 26 27 |
# File 'lib/html_tables/yielded_object.rb', line 25 def radio(id = nil, = { }) t.columns[id] = .reverse_merge! radio: true, align: :center end |
#row_class(cls, options = { }) ⇒ Object
52 53 54 |
# File 'lib/html_tables/yielded_object.rb', line 52 def row_class(cls, = { }) t.row_classes << [cls, ] end |