Class: Tableasy::Formatter

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

Defined Under Namespace

Classes: Column

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Formatter

Returns a new instance of Formatter.



29
30
31
32
# File 'lib/tableasy/formatter.rb', line 29

def initialize(&block)
  @block = block
  @format_header = Proc.new {|header| header.to_sym }
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



27
28
29
# File 'lib/tableasy/formatter.rb', line 27

def block
  @block
end

Instance Method Details

#format_header(header = nil, &block) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/tableasy/formatter.rb', line 34

def format_header(header = nil, &block)
  if block
    @format_header = block
  else
    @format_header.call(header)
  end
end