Parent

Files

Class Index [+]

Quicksearch

String

String extensions to use the GZip module.

The methods gzip and gunzip provide an even more simple interface to the ZLib:

  # create a big string
  x = 'a' * 1000
  
  # zip it
  x_gz = x.gzip
  
  # test the result
  puts 'Zipped %d bytes to %d bytes.' % [x.size, x_gz.size]
  #-> Zipped 1000 bytes to 19 bytes.
  
  # unzipping works
  p x_gz.gunzip == x  #-> true

Public Instance Methods

gunzip() click to toggle source

Returns the string, unzipped. See GZip.gunzip

    # File lib/coderay/helpers/gzip_simple.rb, line 70
70:   def gunzip
71:     GZip.gunzip self
72:   end
gunzip!() click to toggle source

Replaces the string with its unzipped value. See GZip.gunzip

    # File lib/coderay/helpers/gzip_simple.rb, line 75
75:   def gunzip!
76:     replace gunzip
77:   end
gzip(level = GZip::DEFAULT_GZIP_LEVEL) click to toggle source

Returns the string, zipped. level is the gzip compression level, see GZip.gzip.

    # File lib/coderay/helpers/gzip_simple.rb, line 81
81:   def gzip level = GZip::DEFAULT_GZIP_LEVEL
82:     GZip.gzip self, level
83:   end
gzip!(*args) click to toggle source

Replaces the string with its zipped value. See GZip.gzip.

    # File lib/coderay/helpers/gzip_simple.rb, line 86
86:   def gzip!(*args)
87:     replace gzip(*args)
88:   end
to_unix() click to toggle source

I love this hack. It seems to silence all dos/unix/mac newline problems.

     # File lib/coderay/scanner.rb, line 285
285:   def to_unix
286:     if index \r\
287:       gsub(/\r\n?/, "\n")
288:     else
289:       self
290:     end
291:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.