Class: Paperclip::PhantomProcessor

Inherits:
Processor
  • Object
show all
Defined in:
lib/paperclip_processors/phantom_processor.rb

Overview

Phantom SVG processor for Paperclip

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, options = {}, attachment = nil) ⇒ PhantomProcessor

Returns a new instance of PhantomProcessor.



8
9
10
11
12
13
14
15
16
17
# File 'lib/paperclip_processors/phantom_processor.rb', line 8

def initialize(file, options = {}, attachment = nil)
  super
  @format = options.fetch(:format, :svg)
  @height = options.fetch(:height, 64)
  @width = options.fetch(:width, 64)

  @base_name = File.basename(@file.path, '.*')
  @name = options[:output_name] || @base_name
  @svg = Phantom::SVG::Base.new(@file.path)
end

Instance Attribute Details

#dstObject

Returns the value of attribute dst.



7
8
9
# File 'lib/paperclip_processors/phantom_processor.rb', line 7

def dst
  @dst
end

#fileObject

Returns the value of attribute file.



7
8
9
# File 'lib/paperclip_processors/phantom_processor.rb', line 7

def file
  @file
end

#formatObject

Returns the value of attribute format.



7
8
9
# File 'lib/paperclip_processors/phantom_processor.rb', line 7

def format
  @format
end

#heightObject

Returns the value of attribute height.



7
8
9
# File 'lib/paperclip_processors/phantom_processor.rb', line 7

def height
  @height
end

#widthObject

Returns the value of attribute width.



7
8
9
# File 'lib/paperclip_processors/phantom_processor.rb', line 7

def width
  @width
end

Instance Method Details

#makeObject



19
20
21
22
23
24
25
26
# File 'lib/paperclip_processors/phantom_processor.rb', line 19

def make
  case @format.to_sym
  when  :svg then _create_svg
  when  :png then _create_png
  else
    raise 'Format not supported'
  end
end