Class: Pdf::Reader::ExtractImages::Raw

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf/reader/extract_images/raw.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stream, data = stream.unfiltered_data) ⇒ Raw

Returns a new instance of Raw.



5
6
7
8
# File 'lib/pdf/reader/extract_images/raw.rb', line 5

def initialize(stream, data = stream.unfiltered_data)
  @stream = stream
  @data = data
end

Instance Attribute Details

#streamObject (readonly)

Returns the value of attribute stream.



3
4
5
# File 'lib/pdf/reader/extract_images/raw.rb', line 3

def stream
  @stream
end

Instance Method Details

#save(filename) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/pdf/reader/extract_images/raw.rb', line 10

def save(filename)
  case @stream.hash[:ColorSpace]
  when :DeviceCMYK then save_cmyk(filename)
  when :DeviceGray then save_gray(filename)
  when :DeviceRGB  then save_rgb(filename)
  else
    if @stream.hash[:ColorSpace].is_a?(Array)
      if @stream.hash[:ColorSpace].include?(:DeviceCMYK)
        return save_cmyk(filename)
      elsif @stream.hash[:ColorSpace].include?(:DeviceRGB)
        return save_rgb(filename)
      elsif @stream.hash[:ColorSpace].include?(:DeviceGray)
        return save_gray(filename)
      end
    end
    warn "unsupport color depth #{@stream.hash[:ColorSpace]} #{filename}"
  end
end