Module: Emf2svg

Extended by:
FFI::Library
Defined in:
lib/emf2svg.rb,
lib/emf2svg/recipe.rb,
lib/emf2svg/version.rb

Defined Under Namespace

Classes: Error, GeneratorOptions, Recipe

Constant Summary collapse

LIBEMF2SVG_VERSION =

Gem version follows the pattern:

{LIBEMF2SVG_VERSION}.{LIBEMF2SVG_RUBY_ITERATION}

where LIBEMF2SVG_VERSION is the upstream libemf2svg release this gem is built against, and LIBEMF2SVG_RUBY_ITERATION is a counter for Ruby-side changes (recipe bug fixes, CI changes, docs) that bump without a new libemf2svg release. The iteration resets to 0 each time LIBEMF2SVG_VERSION bumps.

See README.adoc -> "Versioning" for the rationale and examples.

"1.8.2"
LIBEMF2SVG_RUBY_ITERATION =
1
VERSION =
"#{LIBEMF2SVG_VERSION}.#{LIBEMF2SVG_RUBY_ITERATION}"

Class Method Summary collapse

Class Method Details

.from_binary_string(content, width = 0, height = 0) ⇒ Object

Raises:



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/emf2svg.rb', line 47

def from_binary_string(content, width = 0, height = 0)
  svg_out = FFI::MemoryPointer.new(:pointer)
  svg_out_len = FFI::MemoryPointer.new(:pointer)
  content_ptr = FFI::MemoryPointer.from_string(content)

  opt = options(width, height)
  ret = emf2svg(content_ptr, content.size, svg_out, svg_out_len, opt)
  raise Error, "emf2svg failed with error code: #{ret}" unless ret == 1

  svg_out.read_pointer.read_bytes(svg_out_len.read_int)
end

.from_file(path, width = 0, height = 0) ⇒ Object



42
43
44
45
# File 'lib/emf2svg.rb', line 42

def from_file(path, width = 0, height = 0)
  content = File.read(path, mode: "rb")
  from_binary_string(content, width, height)
end