[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby-SVG problems with Style attributes

grr ruby svg freek

6/8/2006 12:42:00 PM

So I found an excellent SVG class made by Yuya at
http://raa.ruby-lang.org/projec... - Thank you Yuya!

Its very nice piece of work, but I have one problem with Style attributes
that contain the "-" character (minus), such as ":stroke-width" or
"fill-opacity". Attributes without "-" function ok (such as ":fill" or
":stroke"".

Could this be caused by my editors character set?

**Details:

**Error message:
MFriend-rubysvg-tst-v0.1.rb:41: undefined local variable or method `width' for #<SVG::Ellipse:0xb7cd5034> (NameError)
from ./svg/element.rb:23:in `initialize'
from ./svg/element.rb:176:in `initialize'
from MFriend-rubysvg-tst-v0.1.rb:37
from MFriend-rubysvg-tst-v0.1.rb:27
**Line 41 reads as:
self.style = SVG::Style.new(:stroke-width => wid)

If I read the Style.rb source code (thats a module loaded by element.rb),
I can clearly see the following definition for the stroke-width attribute:
**quote
Attributes = [
....
'stroke-opacity', #
'stroke-width', #
'fill', #
....
etc. etc.

What to do?!? Fill-attribute works fine...

Please help! Thank you.

Gir (please reply to newsgroup)
2 Answers

ts

6/8/2006 1:05:00 PM

0

>>>>> "g" == grr ruby svg freek <grr@rubysvgfreex.org> writes:

g> self.style = SVG::Style.new(:stroke-width => wid)

This is ruby which give the error, it interpret

:stroke-width

as

:stroke - width

Try it with a string

self.style = SVG::Style.new("stroke-width" => wid)

to see if it work or with

self.style = SVG::Style.new(:stroke_width => wid)

underscore rather than -



--

Guy Decoux

grr ruby svg freek

6/8/2006 1:14:00 PM

0

I found a workaround: I wrapped the attributes with the "-"-character
inside double quotes; literally: ":stroke-width" if you get the drift :)

Girrrrrrrr
On Thu, 08 Jun 2006 15:41:35 +0300, grr ruby svg freek wrote:

> So I found an excellent SVG class made by Yuya at
> http://raa.ruby-lang.org/projec... - Thank you Yuya!
>
> Its very nice piece of work, but I have one problem with Style attributes
> that contain the "-" character (minus), such as ":stroke-width" or
> "fill-opacity". Attributes without "-" function ok (such as ":fill" or
> ":stroke"".