Class: SVG::Text

Inherits:
ElementBase show all
Defined in:
lib/ruby-svg/element.rb

Overview

#

Text Class

Instance Attribute Summary collapse

Attributes inherited from ElementBase

#attr, #class, #id, #style, #transform

Instance Method Summary collapse

Constructor Details

#initialize(x, y, text) ⇒ Text

Returns a new instance of Text.



313
314
315
316
317
318
319
320
# File 'lib/ruby-svg/element.rb', line 313

def initialize(x, y, text)
  super()
  @x             = x
  @y             = y
  @text          = text
  @length        = nil
  @length_adjust = nil
end

Instance Attribute Details

#lengthObject

Returns the value of attribute length.



322
323
324
# File 'lib/ruby-svg/element.rb', line 322

def length
  @length
end

#length_adjustObject

Returns the value of attribute length_adjust.



322
323
324
# File 'lib/ruby-svg/element.rb', line 322

def length_adjust
  @length_adjust
end

#textObject

Returns the value of attribute text.



322
323
324
# File 'lib/ruby-svg/element.rb', line 322

def text
  @text
end

#xObject

Returns the value of attribute x.



322
323
324
# File 'lib/ruby-svg/element.rb', line 322

def x
  @x
end

#yObject

Returns the value of attribute y.



322
323
324
# File 'lib/ruby-svg/element.rb', line 322

def y
  @y
end

Instance Method Details

#to_sObject



324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/ruby-svg/element.rb', line 324

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