lib/osheet/column.rb in osheet-0.4.0 vs lib/osheet/column.rb in osheet-0.5.0
- old
+ new
@@ -1,34 +1,38 @@
module Osheet
class Column
+ include Instance
include WorkbookElement
include WorksheetElement
include StyledElement
include MetaElement
def initialize(workbook=nil, worksheet=nil, *args, &block)
- @workbook = workbook
- @worksheet = worksheet
- @width = nil
- @autofit = false
- @hidden = false
- instance_exec(*args, &block) if block_given?
+ set_ivar(:workbook, workbook)
+ set_ivar(:worksheet, worksheet)
+ set_ivar(:width, nil)
+ set_ivar(:autofit, false)
+ set_ivar(:hidden, false)
+ if block_given?
+ set_binding_ivars(block.binding)
+ instance_exec(*args, &block)
+ end
end
def width(value=nil)
- !value.nil? ? @width = value : @width
+ !value.nil? ? set_ivar(:width, value) : get_ivar(:width)
end
- def autofit(value); @autofit = !!value; end
- def autofit?; @autofit; end
- def hidden(value); @hidden = !!value; end
- def hidden?; @hidden; end
+ def autofit(value); set_ivar(:autofit, !!value); end
+ def autofit?; get_ivar(:autofit); end
+ def hidden(value); set_ivar(:hidden, !!value); end
+ def hidden?; get_ivar(:hidden); end
def attributes
{
- :style_class => @style_class,
- :width => @width,
- :autofit => @autofit,
- :hidden => @hidden
+ :style_class => get_ivar(:style_class),
+ :width => get_ivar(:width),
+ :autofit => get_ivar(:autofit),
+ :hidden => get_ivar(:hidden)
}
end
end
end