From: Robert Klemme Date: 2012-08-08T21:15:27+09:00 Subject: Re: Initializer with self On Wed, Aug 8, 2012 at 2:05 PM, Iwan B. wrote: > This is the 'real' case (used for .xlsx files generation, via axlsx > gem): > p = Axlsx::Package.new > wb = p.workbook Well, you could do class MyPackage < ::Axlsx::Package class MyWorkbook < ::Axlsx::Workbook def initialize(*a, &b) super # add styles end end def workbook MyWorkbook.new(self) end end Or, if you just want to add default styles and values you could do def ::Axlsx::Workbook.my_workbook workbook.tap do |wb| wb.styles.add_style sz: 16, b: true, alignment: { horizontal: :center } ... end end > wb.styles.add_style sz: 16, b: true, alignment: { horizontal: :center } > wb.add_worksheet(:name => "Basic Worksheet") do |sheet| > ... > > I don't need the package object 'p', except for get a workbook. It _may_ be stored inside the workbook. Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/