Ruby-SVG problems with Style attributes

  • Thread starter grr ruby svg freek
  • Start date
G

grr ruby svg freek

So I found an excellent SVG class made by Yuya at
http://raa.ruby-lang.org/project/ruby-svg - 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)
 
T

ts

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 -
 
G

grr ruby svg freek

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

Girrrrrrrr
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top