Class: TableCreator::Row

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(row, parent, options = {}) ⇒ Row

Returns a new instance of Row.



7
8
9
10
11
12
13
14
15
# File 'lib/table_creator/row.rb', line 7

def initialize(row, parent, options = {})
  @parent = parent
  @options = options
  @cols  = []
  row.each do |col|
    @cols << Col.new(col, row, options[:type])
  end
  self
end

Instance Attribute Details

#colsObject

Returns the value of attribute cols.



5
6
7
# File 'lib/table_creator/row.rb', line 5

def cols
  @cols
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/table_creator/row.rb', line 5

def options
  @options
end

#parentObject

Returns the value of attribute parent.



5
6
7
# File 'lib/table_creator/row.rb', line 5

def parent
  @parent
end

Instance Method Details

#to_csvObject



17
18
19
# File 'lib/table_creator/row.rb', line 17

def to_csv
  cols.map(&:to_csv).flatten.join(',')
end

#to_htmlObject



21
22
23
# File 'lib/table_creator/row.rb', line 21

def to_html
   :tr, cols.map(&:to_html).join.html_safe, options.except(:type)
end