Class: SvgStack
- Inherits:
-
Object
- Object
- SvgStack
- Defined in:
- lib/svgstack.rb
Instance Attribute Summary collapse
-
#css ⇒ Object
Returns the value of attribute css.
Instance Method Summary collapse
-
#initialize(data = nil, x: 0, y: 0, width: 150, height: nil) ⇒ SvgStack
constructor
A new instance of SvgStack.
- #save(file = 'untitled') ⇒ Object
Constructor Details
#initialize(data = nil, x: 0, y: 0, width: 150, height: nil) ⇒ SvgStack
Returns a new instance of SvgStack.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/svgstack.rb', line 28 def initialize(data=nil, x: 0, y: 0, width: 150, height: nil) boxes = data if data.is_a? Array height ||= (boxes.length * 50) + 50 @svg = Victor::SVG.new viewBox: [x, y, width, height].join(' ') @boxwidth = width build boxes @css = " rect { fill: #f6f; } text { fill: blue} " end |
Instance Attribute Details
#css ⇒ Object
Returns the value of attribute css.
26 27 28 |
# File 'lib/svgstack.rb', line 26 def css @css end |
Instance Method Details
#save(file = 'untitled') ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/svgstack.rb', line 48 def save(file='untitled') @svg.save file #inject the css s = File.read file s2 = s.lines.insert 7, css_code() File.write file, s2.join end |