#SVG Class Reference
The Victor::SVG
(and Victor::SVGBase
) class provides a foundation for creating SVG graphics in Ruby. It supports custom templates, CSS styling, and flexible SVG element generation.
#Initialization
##initialize
Creates a new instance of SVG
.
#Building
##tag
/ #element
Adds an SVG element to the content.
- If
value
is a Hash, it's treated asattributes
. - If
name
ends with!
, the content is not XML-escaped. - This method is the target for
method_missing
, enabling dynamic element names.
##build
Evaluates a block in the context of the SVG instance, allowing dynamic SVG content creation.
##append
/ #embed
/ #<<
Adds content from another source to the SVG. This can be used to compose SVG using other SVG objects.
##css
Manages CSS definitions for the SVG.
#Rendering / Saving
##save
Saves the SVG content to a file.
##render
Renders the full SVG string, including its CSS and SVG header.
##to_s
Converts the SVG content to a string. This method is used internally to join the SVG content with the specified glue
.
Note
The string output provided by #to_s
does not include the CSS or the SVG header. If you want the full SVG string, see #render
#Internal / Special Use
##setup
Sets up the initial attributes for the SVG.
This method is used internally, and by the DSL and typically not required for basic usage.
#
Manages the array of SVG lines. This is used internally to assemble the SVG content.
##svg_attributes
Holds the attributes for the SVG element, such as width
, height
, and other SVG attributes.
##template
Specifies the SVG template to use. This is rarely needed as the default template is often sufficient.
##glue
Specifies the string to use between SVG elements. This is rarely needed as the default glue is often sufficient.