Class: Quadtone::Tools::Render

Inherits:
Quadtone::Tool show all
Defined in:
lib/quadtone/tools/render.rb

Instance Attribute Summary collapse

Attributes inherited from Quadtone::Tool

#profile, #verbose

Instance Method Summary collapse

Methods inherited from Quadtone::Tool

#load_profile, #parse_global_option, process_args, #process_environment

Instance Attribute Details

#desired_sizeObject

Returns the value of attribute desired_size.



10
11
12
# File 'lib/quadtone/tools/render.rb', line 10

def desired_size
  @desired_size
end

#page_sizeObject

Returns the value of attribute page_size.



9
10
11
# File 'lib/quadtone/tools/render.rb', line 9

def page_size
  @page_size
end

#resolutionObject

Returns the value of attribute resolution.



8
9
10
# File 'lib/quadtone/tools/render.rb', line 8

def resolution
  @resolution
end

#rotateObject

Returns the value of attribute rotate.



7
8
9
# File 'lib/quadtone/tools/render.rb', line 7

def rotate
  @rotate
end

Instance Method Details

#parse_option(option, args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/quadtone/tools/render.rb', line 12

def parse_option(option, args)
  case option
  when '--rotate'
    @rotate = true
  when '--resolution'
    @resolution = args.shift.to_f
  when '--page-size'
    @page_size = @profile.printer.page_size(args.shift)
  when '--desired-size'
    width, height = args.shift.split('x').map(&:to_f)
    @desired_size = HashStruct.new(width: width, height: height)
  end
end

#run(*args) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/quadtone/tools/render.rb', line 26

def run(*args)
  options = {}
  options.merge!(rotate: @rotate) if @rotate
  options.merge!(resolution: @resolution) if @resolution
  options.merge!(page_size: @page_size) if @page_size
  options.merge!(desired_size: @desired_size) if @desired_size
  renderer = Renderer.new(options)
  args.map { |p| Path.new(p) }.each do |input_path|
    output_paths = renderer.render(input_path)
    ;;warn "\t" + "Wrote rendered file to #{output_paths.join(', ')}"
  end
end