Class: Table

Inherits:
Object
  • Object
show all
Defined in:
lib/bean/table.rb

Instance Method Summary collapse

Constructor Details

#initialize(map) ⇒ Table

Returns a new instance of Table.



6
7
8
9
10
# File 'lib/bean/table.rb', line 6

def initialize(map)
  @map = map
  @left_dash = 20
  @right_dash = 20
end

Instance Method Details

#tableObject



12
13
14
15
16
17
18
19
20
# File 'lib/bean/table.rb', line 12

def table
  r = header
  for (key, value) in @map 
    left = @left_dash - key.to_s.length
    right = @right_dash - value.to_s.length
    r << "| #{key}#{indent(left)} | #{value}#{indent(right)} |\n"
  end
  r << line
end