Class: Scruffy::Components::StyleInfo

Inherits:
Base
  • Object
show all
Defined in:
lib/scruffy/components/style_info.rb

Overview

Component used for adding CSS styling to SVG graphs.

In hindsight, ImageMagick and Mozilla SVG’s handling of CSS styling is extremely inconsistant, so use this at your own risk.

Instance Attribute Summary

Attributes inherited from Base

#id, #options, #position, #size, #visible

Instance Method Summary collapse

Methods inherited from Base

#draw, #render

Constructor Details

#initialize(*args) ⇒ StyleInfo

Returns a new instance of StyleInfo.



8
9
10
11
12
# File 'lib/scruffy/components/style_info.rb', line 8

def initialize(*args)
  super
  
  @visible = false
end

Instance Method Details

#process(svg, options = {}) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/scruffy/components/style_info.rb', line 13

def process(svg, options={})
  svg.defs {
    svg.style(:type => "text/css") {
      svg.cdata!("\n#{options[:selector]} {\n    #{options[:style]}\n}\n")
    }
  }
end