Class: SVG::Node
- Inherits:
-
XML::Node
- Object
- XML::Node
- SVG::Node
- Includes:
- NodeHelpers
- Defined in:
- lib/svg/node.rb,
lib/svg/node/path.rb
Overview
Wrapper class around XML::Node, defining the base SVG methods available to all nodes, such as #scale and #transform.
Direct Known Subclasses
Defined Under Namespace
Classes: Path
Instance Method Summary (collapse)
-
- (Object) []=(attribute, value)
Sets the value of an attribute, ensuring that both the key and the value have been converted to strings.
-
- (SVG::Transform) current_transformation
The current transformation object.
-
- (Node) initialize(name, properties = {}) {|SVG::Node| ... }
constructor
Creates a new instance of an SVG node with the given name.
-
- (Object) scale(xscale, yscale = xscale)
Scales the node based on the provided x and y scale factors.
-
- (Object) translate(x, y = 0)
Translates the node based on the provided x and y positions.
-
- (String) xpath
The xpath to the current node.
Methods included from NodeHelpers
#clip_path, #g, #path, #rect
Constructor Details
- (Node) initialize(name, properties = {}) {|SVG::Node| ... }
Creates a new instance of an SVG node with the given name.
31 32 33 34 35 36 37 38 39 |
# File 'lib/svg/node.rb', line 31 def initialize(name, properties = {}) super name properties.each do |property, value| self[property] = value end yield self if block_given? end |
Instance Method Details
- (Object) []=(attribute, value)
Sets the value of an attribute, ensuring that both the key and the value have been converted to strings.
51 52 53 54 55 56 57 58 59 |
# File 'lib/svg/node.rb', line 51 def []=(attribute, value) case value when SVG::Node super attribute.to_s, "url(##{value[:id]})" else super attribute.to_s, value.to_s end end |
- (SVG::Transform) current_transformation
The current transformation object
42 43 44 |
# File 'lib/svg/node.rb', line 42 def current_transformation @current_transformation ||= SVG::Transform.new end |
- (Object) scale(xscale, yscale = xscale)
Scales the node based on the provided x and y scale factors.
67 68 69 70 |
# File 'lib/svg/node.rb', line 67 def scale(xscale, yscale = xscale) current_transformation.scale(xscale, yscale) self["transform"] = current_transformation.to_s end |
- (Object) translate(x, y = 0)
Translates the node based on the provided x and y positions.
78 79 80 81 |
# File 'lib/svg/node.rb', line 78 def translate(x, y = 0) current_transformation.translate(x, y) self["transform"] = current_transformation.to_s end |
- (String) xpath
The xpath to the current node
84 85 86 |
# File 'lib/svg/node.rb', line 84 def xpath _path end |