Class: Vectory::Ps

Inherits:
Vector show all
Defined in:
lib/vectory/ps.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

.default_extensionObject



7
8
9
# File 'lib/vectory/ps.rb', line 7

def self.default_extension
  "ps"
end

.from_node(node) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/vectory/ps.rb', line 15

def self.from_node(node)
  return from_content(node.children.to_xml) unless node.text.strip.empty?

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

  from_path(uri)
end

.mimetypeObject



11
12
13
# File 'lib/vectory/ps.rb', line 11

def self.mimetype
  "application/postscript"
end

Instance Method Details

#heightObject



36
37
38
39
40
41
# File 'lib/vectory/ps.rb', line 36

def height
  bbox = parse_bounding_box
  return super unless bbox

  bbox[:ury] - bbox[:lly]
end

#to_emfObject



28
29
30
# File 'lib/vectory/ps.rb', line 28

def to_emf
  to_svg.to_emf
end

#to_epsObject



24
25
26
# File 'lib/vectory/ps.rb', line 24

def to_eps
  to_svg.to_eps
end

#to_svgObject



32
33
34
# File 'lib/vectory/ps.rb', line 32

def to_svg
  Svg.from_content(Postsvg.convert(content))
end

#widthObject



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

def width
  bbox = parse_bounding_box
  return super unless bbox

  bbox[:urx] - bbox[:llx]
end