lib/osheet/column.rb in osheet-0.1.0 vs lib/osheet/column.rb in osheet-0.2.0

- old
+ new

@@ -1,11 +1,38 @@ -require 'osheet/base' - module Osheet - class Column < Osheet::Base - - def initialize(args={}) - super(args) + class Column + include WorkbookElement + include WorksheetElement + include StyledElement + + def initialize(workbook=nil, worksheet=nil, *args, &block) + @workbook = workbook + @worksheet = worksheet + @width = nil + @autofit = false + @hidden = false + @meta = nil + instance_exec(*args, &block) if block_given? end - + + def width(value=nil) + !value.nil? ? @width = value : @width + end + def autofit(value); @autofit = !!value; end + def autofit?; @autofit; end + def hidden(value); @hidden = !!value; end + def hidden?; @hidden; end + + def attributes + { + :style_class => @style_class, + :width => @width, + :autofit => @autofit, + :hidden => @hidden + } + end + + def meta(value=nil) + value.nil? ? @meta : (@meta = value) + end end end