syntax issue

S

Sig Dx

Hello guys,
I have hard time using Prawn (PDF library).

I need to add to number_pages the font size

Code:
def number_pages(string, position)
page_count.times do |i|
go_to_page(i)
str = string.gsub("<page>","#{i+1}").gsub("<total>","#{page_count}")
text str, :at => position
end
end


so I tried number_pages("<page> / <total>", [0, 0]), :size => 10 but
i get syntax error, unexpected ',', expecting kEND


However text "str", :at => [0, 0], :size => 10 works fine.



Can anyone please let me know the difference between the 2 lines above?

Thanks, I appreciate your help.


Sig
 
A

Aldric Giacomoni

Sig said:
so I tried number_pages("<page> / <total>", [0, 0]), :size => 10 but
i get syntax error, unexpected ',', expecting kEND


However text "str", :at => [0, 0], :size => 10 works fine.
Can anyone please let me know the difference between the 2 lines above?

I've never used prawn, but I notice parenthesis. Why are those there ?
 
S

Seebs

so I tried number_pages("<page> / <total>", [0, 0]), :size => 10 but
i get syntax error, unexpected ',', expecting kEND

Maybe you should have the hash INSIDE the parentheses, if you need them
at all?

The hash is just another argument to number_pages. That means that,
if you're using ()s around the arguments, it needs to be inside them.

-s
 
S

Sig Dx

Thanks for your replies.

I guess you mean something like

number_pages("<page> / <total>", [0,0], :size => 10)

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.

If I'm wrong and you mean something different, can you please write down
a snippet for me?


THANKS AGAIN


Sig
 
G

Gregory Brown

I actually don't agree that it isn't. =A0However, I do agree that the
project mailing list is not the place for basic Ruby syntax questions.

Well that's re-assuring to hear, but at the same time, if you don't
trust me about this, swim at your own risk :)

-greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top