Class: RGhost::Image

Inherits:
PsObject show all
Defined in:
lib/rghost/image.rb

Overview

Super class of GIF and JPEG.

Direct Known Subclasses

Gif, Jpeg

Constant Summary collapse

DEFAULT_OPTIONS =
{:x=> :limit_left, :y=> 1, :zoom => 100, :rotate => 0}

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PsObject

#<<, #call, #graphic_scope, #ps, #raw, #set, #to_s

Constructor Details

#initialize(image_path, options = {}) ⇒ Image

Returns a new instance of Image.



6
7
8
9
10
# File 'lib/rghost/image.rb', line 6

def initialize(image_path,options={})
  super("")
  @options=DEFAULT_OPTIONS.dup.merge(options)
  @file=image_path
end

Class Method Details

.for(path, options = {}) ⇒ Object

Facade method for load image by file extension. Uses Eps, Gif and Jpeg class. Accepts gif, jpeg, jpg and eps



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rghost/image.rb', line 13

def self.for(path,options={})
  
  clazz=case path
    when /gif$/i
      RGhost::Gif
    when /jpe?g$/i
      RGhost::Jpeg
    when /(eps|template)$/i
        RGhost::Eps
    else raise NameError.new("Unsupported format")
  end
  
  clazz.new(path,options)
end