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 = {}) {|_self| ... } ⇒ Tag

Returns a new instance of Tag.

Yields:

  • (_self)

Yield Parameters:



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

def initialize(parent = nil, options = {})
  @parent = parent
  @options = options
  yield self if block_given?
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



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

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

#collection_classObject



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

def collection_class
  table.collection_class
end

#collection_nameObject



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

def collection_name
  table.collection_name
end

#head?Boolean

Returns:

  • (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

Yields:

  • (content = '')


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((tag_name, content, options, escape))
end

#tableObject



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

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