Class: Asciidoctor::Diagram::SvgbobConverter

Inherits:
Object
  • Object
show all
Includes:
CliGenerator, DiagramConverter
Defined in:
lib/asciidoctor-diagram/svgbob/converter.rb

Constant Summary collapse

OPTIONS =
{
    :font_family => lambda { |o, v| o << '--font-family' << v if v },
    :font_size => lambda { |o, v| o << '--font-size' << v if v },
    :stroke_width => lambda { |o, v| o << '--stroke-width' << v if v },
    :scale => lambda { |o, v| o << '--scale' << v if v }
}

Instance Method Summary collapse

Methods included from CliGenerator

#generate_file, #generate_file_stdout, #generate_stdin, #generate_stdin_file, #generate_stdin_stdout

Methods included from DiagramConverter

#wrap_source

Instance Method Details

#collect_options(source) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/asciidoctor-diagram/svgbob/converter.rb', line 28

def collect_options(source)
  options = {}

  OPTIONS.keys.each do |option|
    attr_name = option.to_s.tr('_', '-')
    options[option] = source.attr(attr_name) || source.attr(attr_name, nil, 'svgbob-option')
  end

  options
end

#convert(source, format, options) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/asciidoctor-diagram/svgbob/converter.rb', line 40

def convert(source, format, options)

  flags = []
  options.each do |option, value|
    OPTIONS[option].call(flags, value)
  end
  
  generate_stdin(source.find_command('svgbob'), format.to_s, source.to_s) do |tool_path, output_path|
    ([tool_path, '-o', Platform.native_path(output_path)] + flags)
  end
end

#native_scaling?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/asciidoctor-diagram/svgbob/converter.rb', line 17

def native_scaling?
  true
end

#supported_formatsObject



13
14
15
# File 'lib/asciidoctor-diagram/svgbob/converter.rb', line 13

def supported_formats
  [:svg]
end