Module: Sevgi::Graphics::Mixtures::Export

Defined in:
lib/sevgi/graphics/mixtures/export.rb

Overview

DSL helpers for native SVG export formats.

Instance Method Summary collapse

Instance Method Details

#PDF(path = nil, **kwargs, &block) ⇒ String

Exports the document as PDF.

Parameters:

  • path (String, nil) (defaults to: nil)

    output path or directory

  • kwargs (Hash)

    export options

Returns:

  • (String)

    output path

Raises:

  • (Sevgi::MissingComponentError)

    when sevgi/sundries is unavailable

  • (Sevgi::Sundries::ExportError)

    when native export fails



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/sevgi/graphics/mixtures/export.rb', line 14

def PDF(path = nil, **kwargs, &block)
  begin
    require "sevgi/sundries"

  rescue ::LoadError => e
    raise unless e.path == "sevgi/sundries"

    MissingComponentError.("sevgi/sundries")
  end

  Export(path, **kwargs, format: :pdf, &block)
end

#PNG(path = nil, **kwargs, &block) ⇒ String

Exports the document as PNG.

Parameters:

  • path (String, nil) (defaults to: nil)

    output path or directory

  • kwargs (Hash)

    export options

Returns:

  • (String)

    output path

Raises:

  • (Sevgi::MissingComponentError)

    when sevgi/sundries is unavailable

  • (Sevgi::Sundries::ExportError)

    when native export fails



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/sevgi/graphics/mixtures/export.rb', line 33

def PNG(path = nil, **kwargs, &block)
  begin
    require "sevgi/sundries"

  rescue ::LoadError => e
    raise unless e.path == "sevgi/sundries"

    MissingComponentError.("sevgi/sundries")
  end

  Export(path, **kwargs, format: :png, &block)
end