On Thursday 10 December 2009 03:31:14 pm Sig Dx wrote:
I guess you mean something like
number_pages(“ / ”, [0,0], :size => 10)
Yes, that’s the only way that statement makes any sense, and that’s why
everyone assumed that’s what you meant.
but that doesn’t work for sure; with that code I get wrong number of
arguments (3 for 2) since number_pages requires 2 arguments and with
everything inside the parenthesis the arguments are 3.
Just so. You’ll still need to either find a way to change what
number_pages
does, or you’ll need to do it yourself.
But this isn’t a syntax issue, it’s an issue of the library not already
doing
what you want. For example, the following statement is syntactically
correct:
Bank.open(‘Federal Reserve’).transfer! 1000000000, :to => cayman_account
But, chances are, you don’t have access to a library which can actually
do
what that’s asking for. On the other hand, the following is quite
possible to
do, but syntactically broken:
has_many(:comments) :through => :posts
You see, the options hash gets turned into an argument. If you have
parentheses, that means it has to go inside the parentheses. If that
gives you
an error, it’s possible the function just doesn’t support what you want!
So, define your own number_pages method, and if you find a good way to
do it
generically, send it to the Prawn people.
Here’s what I came up with:
def number_pages(string, position, options={})
page_count.times do |i|
go_to_page(i)
str = string.gsub(“”,“#{i+1}”).gsub(“”,“#{page_count}”)
text str, {:at => position}.merge!(options)
end
end
I’m not sure it’s a good idea for it to work that way, though.
Ask the Prawn people:
http://groups.google.com/group/prawn-ruby