Class: SVG::ElementBase

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

Overview

#

ElementBase Class

Direct Known Subclasses

Anchor, Circle, Ellipse, Group, Image, Line, Path, Polygon, Polyline, Rect, Text, Use

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ ElementBase

Returns a new instance of ElementBase.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ruby-svg/element.rb', line 15

def initialize(&block)
  @id        = nil
  @style     = nil
  @class     = nil
  @transform = nil
  @attr      = nil

  if block_given?
    instance_eval(&block)
  end
end

Instance Attribute Details

#attrObject

Returns the value of attribute attr.



27
28
29
# File 'lib/ruby-svg/element.rb', line 27

def attr
  @attr
end

#classObject

Returns the value of attribute class.



27
28
29
# File 'lib/ruby-svg/element.rb', line 27

def class
  @class
end

#idObject

Returns the value of attribute id.



27
28
29
# File 'lib/ruby-svg/element.rb', line 27

def id
  @id
end

#styleObject

Returns the value of attribute style.



27
28
29
# File 'lib/ruby-svg/element.rb', line 27

def style
  @style
end

#transformObject

Returns the value of attribute transform.



27
28
29
# File 'lib/ruby-svg/element.rb', line 27

def transform
  @transform
end

Instance Method Details

#to_sObject



29
30
31
32
33
34
35
36
37
# File 'lib/ruby-svg/element.rb', line 29

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