Class: Vectory::Emf

Inherits:
Vector show all
Defined in:
lib/vectory/emf.rb

Instance Attribute Summary

Attributes inherited from Vector

#initial_path

Attributes inherited from Image

#content

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Vector

#file_size, from_datauri, from_path, #initialize, #mime, #path, #size, #to_uri, #write

Methods inherited from Image

from_content, from_path, #initialize

Constructor Details

This class inherits a constructor from Vectory::Vector

Class Method Details

.all_mimetypesObject



12
13
14
# File 'lib/vectory/emf.rb', line 12

def self.all_mimetypes
  [mimetype] + alternative_mimetypes
end

.alternative_mimetypesObject



20
21
22
# File 'lib/vectory/emf.rb', line 20

def self.alternative_mimetypes
  ["application/x-msmetafile"]
end

.default_extensionObject



8
9
10
# File 'lib/vectory/emf.rb', line 8

def self.default_extension
  "emf"
end

.from_node(node) ⇒ Object



24
25
26
27
28
29
# File 'lib/vectory/emf.rb', line 24

def self.from_node(node)
  uri = node["src"]
  return Vectory::Datauri.new(uri).to_vector if %r{^data:}.match?(uri)

  from_path(uri)
end

.mimetypeObject



16
17
18
# File 'lib/vectory/emf.rb', line 16

def self.mimetype
  "image/emf"
end

Instance Method Details

#heightObject



43
44
45
46
47
48
# File 'lib/vectory/emf.rb', line 43

def height
  bounds = parse_header_bounds
  return super unless bounds

  bounds.bottom - bounds.top
end

#to_epsObject



35
36
37
# File 'lib/vectory/emf.rb', line 35

def to_eps
  to_svg.to_eps
end

#to_psObject



39
40
41
# File 'lib/vectory/emf.rb', line 39

def to_ps
  to_svg.to_ps
end

#to_svgObject



31
32
33
# File 'lib/vectory/emf.rb', line 31

def to_svg
  Svg.from_content(Emfsvg.from_bytes(content))
end

#widthObject



50
51
52
53
54
55
# File 'lib/vectory/emf.rb', line 50

def width
  bounds = parse_header_bounds
  return super unless bounds

  bounds.right - bounds.left
end