Class: Xsdvi::SVG::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/xsdvi/svg/generator.rb

Overview

Generates SVG files from symbol trees

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(writer) ⇒ Generator

Returns a new instance of Generator.



11
12
13
14
15
16
17
# File 'lib/xsdvi/svg/generator.rb', line 11

def initialize(writer)
  @writer = writer
  @embody_style = true
  @style_uri = nil
  @hide_menu_buttons = false
  @resource_loader = Utils::ResourceLoader.new
end

Instance Attribute Details

#embody_styleObject

Returns the value of attribute embody_style.



9
10
11
# File 'lib/xsdvi/svg/generator.rb', line 9

def embody_style
  @embody_style
end

#hide_menu_buttonsObject

Returns the value of attribute hide_menu_buttons.



9
10
11
# File 'lib/xsdvi/svg/generator.rb', line 9

def hide_menu_buttons
  @hide_menu_buttons
end

#style_uriObject

Returns the value of attribute style_uri.



9
10
11
# File 'lib/xsdvi/svg/generator.rb', line 9

def style_uri
  @style_uri
end

#writerObject

Returns the value of attribute writer.



9
10
11
# File 'lib/xsdvi/svg/generator.rb', line 9

def writer
  @writer
end

Instance Method Details

#draw(root_symbol) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/xsdvi/svg/generator.rb', line 19

def draw(root_symbol)
  # Reset class variables before drawing
  Symbol.reset_class_variables

  svg_begin
  draw_symbol(root_symbol)
  svg_end
end


34
35
36
# File 'lib/xsdvi/svg/generator.rb', line 34

def print(string)
  writer.append("#{string}\n")
end


28
29
30
31
32
# File 'lib/xsdvi/svg/generator.rb', line 28

def print_extern_style
  writer.new_writer(style_uri)
  print(load_resource("svg/style.css"))
  writer.close
end