From: Austin Ziegler Date: 2005-03-16T00:27:22+09:00 Subject: Re: Advice on PDF::Writer On Tue, 15 Mar 2005 23:02:23 +0900, gabriele renzi wrote: > Austin Ziegler ha scritto: >> Hi, folks. I'm in the middle of a major overhaul to PDF::Writer. >> The API is changing significantly. Here are a couple of changes: >> >> # Set the stroke style. Assume a PDF object instance. >> pdf.set_stroke_style(5, :round, :bevel, [3, 5], 1) >> # becomes >> PDF::Writer::StrokeStyle.new(5) do |ss| >> ss.cap = :round >> ss.join = :bevel >> ss.dash = { :pattern => [ 3, 5 ], :phase => 1 } >> pdf.stroke_style ss >> end > question: why this is not: > pdf.stroke_style = ss > (this is a question valid for a lot of examples you just showed) > > It seem to me that your convention would make sense in the case > you used a TkRuby-like approach by doing initialization with an > instance-evaled block, but looking at the StrokeStyle > initialization above it does not seem so. This is partially because of internal implementation issues. The table code draws lines around tables: stroke_style StrokeStyle.new(options[:inner_line]) If I used the assignment form, I would need: self.stroke_style = StrokeStyle.new(options[:inner_line]) I have also been debating switching from the yield form to the instance_eval form, but I am undecided as yet. It will not make a significant difference in the code as I've written it; mostly it will be a difference in documentation. -austin -- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca