Class: SimpleTable::Tag

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TagHelper
Defined in:
lib/simple_table/tag.rb

Direct Known Subclasses

Cell, Row, Rows, Table

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent = nil, options = {}) ⇒ Tag

Returns a new instance of Tag.



9
10
11
12
# File 'lib/simple_table/tag.rb', line 9

def initialize(parent = nil, options = {})
  @parent = parent
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/simple_table/tag.rb', line 7

def options
  @options
end

#parentObject (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



36
37
38
# File 'lib/simple_table/tag.rb', line 36

def add_class(klass)
  add_class!(options, klass)
end

#collection_classObject



14
15
16
# File 'lib/simple_table/tag.rb', line 14

def collection_class
  table.collection_class
end

#collection_nameObject



18
19
20
# File 'lib/simple_table/tag.rb', line 18

def collection_name
  table.collection_name
end

#head?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/simple_table/tag.rb', line 26

def head?
  is_a?(Head) || !!parent.try(:head?)
end

#render(content = nil, escape = false) {|content = ''| ... } ⇒ Object

Yields:

  • (content = '')


30
31
32
33
34
# File 'lib/simple_table/tag.rb', line 30

def render(content = nil, escape = false)
  yield(content = '') if content.nil? && block_given?
  content = lf(indent(content.to_s))
  lf((tag_name, content, options, escape))
end

#tableObject



22
23
24
# File 'lib/simple_table/tag.rb', line 22

def table
  is_a?(Table) ? self : parent.try(:table)
end