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.
9 10 11 12 13 |
# File 'lib/simple_table/tag.rb', line 9 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.
7 8 9 |
# File 'lib/simple_table/tag.rb', line 7 def @options end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
7 8 9 |
# File 'lib/simple_table/tag.rb', line 7 def parent @parent end |
Instance Method Details
#add_class(klass) ⇒ Object
37 38 39 |
# File 'lib/simple_table/tag.rb', line 37 def add_class(klass) add_class!(, klass) end |
#collection_class ⇒ Object
15 16 17 |
# File 'lib/simple_table/tag.rb', line 15 def collection_class table.collection_class end |
#collection_name ⇒ Object
19 20 21 |
# File 'lib/simple_table/tag.rb', line 19 def collection_name table.collection_name end |
#head? ⇒ Boolean
27 28 29 |
# File 'lib/simple_table/tag.rb', line 27 def head? is_a?(Head) || !!parent.try(:head?) end |
#render(content = nil, escape = false) {|content = ''| ... } ⇒ Object
31 32 33 34 35 |
# File 'lib/simple_table/tag.rb', line 31 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
23 24 25 |
# File 'lib/simple_table/tag.rb', line 23 def table is_a?(Table) ? self : parent.try(:table) end |