| Computers Forum Index » Computer Languages (Ruby) » Ruby-SVG problems with Style attributes |
|
Page 1 of 1 |
|
| Author |
Message |
| grr ruby svg freek |
Posted: Thu Jun 08, 2006 4:41 pm |
|
|
|
Guest
|
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) |
|
|
| Back to top |
|
|
|
| ts |
Posted: Thu Jun 08, 2006 5:05 pm |
|
|
|
Guest
|
Quote: "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 |
|
|
| Back to top |
|
|
|
| grr ruby svg freek |
Posted: Thu Jun 08, 2006 5:13 pm |
|
|
|
Guest
|
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:
Quote: 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"". |
|
|
| Back to top |
|
|
|
|