Class: Batik::Rasterizer

Inherits:
Object
  • Object
show all
Defined in:
lib/batik/rasterizer.rb

Defined Under Namespace

Classes: RuntimeException

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Rasterizer



9
10
11
12
13
14
15
16
17
18
# File 'lib/batik/rasterizer.rb', line 9

def initialize(options = {})
  @options = options
  @command = [
    path_to_java,
    '-Djava.awt.headless=true',
    '-jar',
    path_to_jar_file,
    command_options
  ]
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



7
8
9
# File 'lib/batik/rasterizer.rb', line 7

def command
  @command
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/batik/rasterizer.rb', line 7

def options
  @options
end

Instance Method Details

#command_optionsObject

private



27
28
29
# File 'lib/batik/rasterizer.rb', line 27

def command_options
  options.map {|name, argument| "-#{name} #{argument}"}
end

#path_to_jar_fileObject



35
36
37
38
# File 'lib/batik/rasterizer.rb', line 35

def path_to_jar_file
  options.delete(:jar_file) ||
    File.join(File.dirname(__FILE__), *%w".. .. vendor batik-1.7 batik-rasterizer.jar")
end

#path_to_javaObject



31
32
33
# File 'lib/batik/rasterizer.rb', line 31

def path_to_java
  options.delete(:java) || "java"
end

#rasterize(file) ⇒ Object



20
21
22
23
# File 'lib/batik/rasterizer.rb', line 20

def rasterize(file)
  command << file
  Open3.popen3(command.join(' ')){|_,_,err| err.read.empty? }
end