/usr/lib/ruby/1.8/svg/element.rb is in libsvg-ruby1.8 1.0.3-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | #==============================================================================#
# svg/element.rb
# $Id: element.rb,v 1.14 2003/02/06 14:59:43 yuya Exp $
#==============================================================================#
#==============================================================================#
# SVG Module
module SVG
#============================================================================#
# ElementBase Class
class ElementBase
def initialize(&block)
@id = nil
@style = nil
@class = nil
@transform = nil
@attr = nil
if block_given?
instance_eval(&block)
end
end
attr_accessor :id, :style, :class, :transform, :attr
def to_s
text = ''
text << %| id="#{@id}"| if @id
text << %| style="#{@style}"| if @style
text << %| class="#{@class}"| if @class
text << %| transform="#{@transform}"| if @transform
text << %| #{@attr}| if @attr
return text
end
end # ElementBase
#============================================================================#
# Group Class
class Group < ElementBase
include ArrayMixin
def initialize
super()
@elements = []
end
attr_reader :elements
def array
return @elements
end
private :array
def to_s
text = %|<g|
text << super()
text << %|>\n|
text << @elements.collect { |element| element.to_s + "\n" }.join
text << %|</g>\n|
end
end # Group
#============================================================================#
# Anchor Class
class Anchor < ElementBase
include ArrayMixin
def initialize(uri)
super()
@uri = uri
@elements = []
end
attr_accessor :uri
attr_reader :elements
def array
return @elements
end
private :array
def to_s
text = %|<a|
text << super()
text << %| xlink:href="#{@uri}">\n|
text << @elements.collect { |element| element.to_s + "\n" }.join
text << %|</a>\n|
end
end # Anchor
#============================================================================#
# Use Class
class Use < ElementBase
def initialize(uri)
super()
@uri = uri
end
attr_accessor :uri
def to_s
text = %|<use|
text << super()
text << %| xlink:href="#{@uri}"/>\n|
end
end # Use
#============================================================================#
# Rect Class
class Rect < ElementBase
def initialize(x, y, width, height, rx = nil, ry = nil)
super()
@x = x
@y = y
@width = width
@height = height
@rx = rx
@ry = ry
end
attr_accessor :width, :height, :x, :y, :rx, :ry
def to_s
text = %|<rect width="#{@width}" height="#{@height}"|
text << %| x="#{@x}"| if @x
text << %| y="#{@y}"| if @y
text << %| rx="#{@rx}"| if @rx
text << %| ry="#{@ry}"| if @ry
text << super()
text << %| />|
return text
end
end # Rect
#============================================================================#
# Circle Class
class Circle < ElementBase
def initialize(cx, cy, r)
super()
@cx = cx
@cy = cy
@r = r
end
attr_accessor :cx, :cy, :r
def to_s
text = %|<circle cx="#{@cx}" cy="#{@cy}" r="#{@r}"|
text << super()
text << %| />|
return text
end
end # Circle
#============================================================================#
# Ellipse Class
class Ellipse < ElementBase
def initialize(cx, cy, rx, ry)
super()
@cx = cx
@cy = cy
@rx = rx
@ry = ry
end
attr_accessor :cx, :cy, :rx, :ry
def to_s
text = %|<ellipse cx="#{@cx}" cy="#{@cy}" rx="#{@rx}" ry="#{@ry}"|
text << super()
text << %| />|
return text
end
end # Ellipse
#============================================================================#
# Line Class
class Line < ElementBase
def initialize(x1, y1, x2, y2)
super()
@x1 = x1
@y1 = y1
@x2 = x2
@y2 = y2
end
attr_accessor :x1, :y1, :x2, :y2
def to_s
text = %|<line x1="#{@x1}" y1="#{@y1}" x2="#{@x2}" y2="#{@y2}"|
text << super()
text << %| />|
return text
end
end # Line
#============================================================================#
# Polyline Class
class Polyline < ElementBase
def initialize(points)
super()
@points = points
end
attr_accessor :points
def to_s
text = %|<polyline points="#{@points.join(' ')}"|
text << super()
text << %| />|
return text
end
end # Polyline
#============================================================================#
# Polygon Class
class Polygon < ElementBase
def initialize(points)
super()
@points = points
end
attr_accessor :points
def to_s
text = %|<polygon points="#{@points.join(' ')}"|
text << super()
text << %| />|
return text
end
end # Polygon
#============================================================================#
# Image Class
class Image < ElementBase
def initialize(x, y, width, height, href)
super()
@x = x
@y = y
@width = width
@height = height
@href = href
end
attr_accessor :x, :y, :width, :height, :href
def to_s
text = %|<image|
text << %| x="#{@x}"| if @x
text << %| y="#{@y}"| if @y
text << %| width="#{@width}"|
text << %| height="#{@height}"|
text << %| xlink:href="#{@href}"|
text << super()
text << %| />|
return text
end
end # Image
#============================================================================#
# Path Class
class Path < ElementBase
def initialize(path, length = nil)
super()
@path = path
@length = length
end
attr_accessor :path, :length
def to_s
text = %|<path d="#{@path.join(' ')}"|
text = %| length="#{@length}"| if @length
text << super()
text << %| />|
return text
end
end # Path
#============================================================================#
# Text Class
class Text < ElementBase
def initialize(x, y, text)
super()
@x = x
@y = y
@text = text
@length = nil
@length_adjust = nil
end
attr_accessor :x, :y, :text, :length, :length_adjust
def to_s
svg = %|<text|
svg << %| x="#{@x}"| if @x
svg << %| y="#{@y}"| if @y
svg << %| textLength="#{@length}"| if @length
svg << %| lengthAdjust="#{@length_adjust}"| if @length_adjust
svg << super()
svg << %|>|
svg << text
svg << %|</text>|
return svg
end
end # Text
#============================================================================#
# Verbatim Class
class Verbatim
def initialize(xml)
@xml = xml
end
attr_accessor :xml
def to_s
return @xml
end
end # Verbatim
end # SVG
#==============================================================================#
#==============================================================================#
|