Class: SimpleTable::Tag
- Inherits:
-
Object
- Object
- SimpleTable::Tag
- Includes:
- ActionView::Helpers::TagHelper
- Defined in:
- lib/simple_table/tag.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #add_class(klass) ⇒ Object
- #collection_class ⇒ Object
- #collection_name ⇒ Object
- #head? ⇒ Boolean
-
#initialize(parent = nil, options = {}) {|_self| ... } ⇒ Tag
constructor
A new instance of Tag.
- #render(content = nil, escape = false) {|content = ''| ... } ⇒ Object
- #table ⇒ Object
Constructor Details
#initialize(parent = nil, options = {}) {|_self| ... } ⇒ Tag
Returns a new instance of Tag.
11 12 13 14 15 |
# File 'lib/simple_table/tag.rb', line 11 def initialize(parent = nil, = {}) @parent = parent @options = yield self if block_given? end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/simple_table/tag.rb', line 9 def @options end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
9 10 11 |
# File 'lib/simple_table/tag.rb', line 9 def parent @parent end |
Instance Method Details
#add_class(klass) ⇒ Object
39 40 41 |
# File 'lib/simple_table/tag.rb', line 39 def add_class(klass) add_class!(, klass) end |
#collection_class ⇒ Object
17 18 19 |
# File 'lib/simple_table/tag.rb', line 17 def collection_class table.collection_class end |
#collection_name ⇒ Object
21 22 23 |
# File 'lib/simple_table/tag.rb', line 21 def collection_name table.collection_name end |
#head? ⇒ Boolean
29 30 31 |
# File 'lib/simple_table/tag.rb', line 29 def head? is_a?(Head) || !!parent.try(:head?) end |
#render(content = nil, escape = false) {|content = ''| ... } ⇒ Object
33 34 35 36 37 |
# File 'lib/simple_table/tag.rb', line 33 def render(content = nil, escape = false) yield(content = '') if content.nil? && block_given? content = lf(indent(content.to_s)) lf(content_tag(tag_name, content, , escape)) end |
#table ⇒ Object
25 26 27 |
# File 'lib/simple_table/tag.rb', line 25 def table is_a?(Table) ? self : parent.try(:table) end |