Browse files

back out changes that make adding filters easier for users

* There's a fairly limited set of filters defined in the PDF spec so
  there should be little need for new filters to be added by users.
  Given that's the case, I'd prefer to keep the Filter class as simple
  as possible
  • Loading branch information...
1 parent aa23a42 commit f877b243df97315c8ad5b6ff5b7d6dbb4a89c106 @yob committed Aug 21, 2011
Showing with 10 additions and 22 deletions.
  1. +10 −22 lib/pdf/reader/filter.rb
View
32 lib/pdf/reader/filter.rb
@@ -32,27 +32,6 @@ class PDF::Reader
#
class Filter # :nodoc:
- @@filters = {
- :ASCII85Decode => :ascii85,
- :ASCIIHexDecode => :asciihex,
- :CCITTFaxDecode => nil,
- :DCTDecode => nil,
- :FlateDecode => :flate,
- :JBIG2Decode => nil,
- :LZWDecode => :lzw,
- :RunLengthDecode => :runlength
- }
-
- class << self
-
- ##############################################################################
- # Return the Hash of supported filters.
- #
- def filters
- @@filters
- end
- end
-
################################################################################
# creates a new filter for decoding content.
#
@@ -62,7 +41,16 @@ def filters
def initialize (name, options = nil)
@options = options
- @filter = @@filters.fetch(name) do
+ case name.to_sym
+ when :ASCII85Decode then @filter = :ascii85
+ when :ASCIIHexDecode then @filter = :asciihex
+ when :CCITTFaxDecode then @filter = nil
+ when :DCTDecode then @filter = nil
+ when :FlateDecode then @filter = :flate
+ when :JBIG2Decode then @filter = nil
+ when :LZWDecode then @filter = :lzw
+ when :RunLengthDecode then @filter = :runlength
+ else
raise UnsupportedFeatureError, "Unknown filter: #{name}"
end
end

0 comments on commit f877b24

Please sign in to comment.