Class: Tableasy::Formatter::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/tableasy/formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, formatter, column, *args) ⇒ Column

Returns a new instance of Column.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/tableasy/formatter.rb', line 6

def initialize(context, formatter, column, *args)
  options = args.extract_options!
  @context = context
  @formatter = formatter
  @args = args
  if options[:no_initial]
    @args.unshift(column)
  else
    @column = column
  end
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



4
5
6
# File 'lib/tableasy/formatter.rb', line 4

def column
  @column
end

Instance Method Details

#execute(cell) ⇒ Object



18
19
20
# File 'lib/tableasy/formatter.rb', line 18

def execute(cell)
  @context.instance_exec(cell, *@args, &@formatter.block)
end

#to_symObject



22
23
24
# File 'lib/tableasy/formatter.rb', line 22

def to_sym
  @formatter.format_header(@column || @args.first)
end