lib/terminal-table/cell.rb in visionmedia-terminal-table-1.1.0 vs lib/terminal-table/cell.rb in visionmedia-terminal-table-1.2.0

- old
+ new

@@ -1,23 +1,32 @@ module Terminal class Table class Cell - attr_accessor :value, :alignment + attr_accessor :value, :alignment, :colspan - def initialize width, value = nil, alignment = :left - @width, @alignment, @value = width, alignment, value + def initialize width, params + @width = width + @alignment = :left + @colspan = 1 + + if params.is_a? Hash + @value = params[:value] + @alignment = params[:alignment] unless params[:alignment].nil? + @colspan = params[:colspan] unless params[:colspan].nil? + else + @value = params + end end def render " #{value.to_s} ".align alignment, @width + 2 end alias :to_s :render def length - value.to_s.length + 2 + @value.to_s.length + 2 end - end end end \ No newline at end of file