### Home Classes Methods

### In Files

- ext/Flate/flate.c

### Methods

- ::compress
- ::expand

### Class/Module Index

Quicksearch

- Tioga
- Tioga::Arcs_and_Circles
- Tioga::ColorConstants
- Tioga::Colorbars
- Tioga::Colormaps
- Tioga::Creating_Paths
- Tioga::Executive
- Tioga::FigureConstants
- Tioga::FigureMaker
- Tioga::Figures_and_Plots
- Tioga::Flate
- Tioga::Images
- Tioga::Legends
- Tioga::MarkerConstants
- Tioga::Markers
- Tioga::Page_Frame_Bounds
- Tioga::Rectangles
- Tioga::Shading
- Tioga::Special_Paths
- Tioga::Strokes
- Tioga::TeX_Text
- Tioga::Titles_and_Labels
- Tioga::Transparency
- Tioga::Tutorial
- Tioga::Tutorial::Animation
- Tioga::Tutorial::CommandLine
- Tioga::Tutorial::DocStructure
- Tioga::Tutorial::Epilog
- Tioga::Tutorial::Figures
- Tioga::Tutorial::OtherStuff
- Tioga::Tutorial::OtherWaysToRunTioga
- Tioga::Tutorial::Plots
- Tioga::Tutorial::SampledData
- Tioga::Tutorial::SimpleFigure
- Tioga::Tutorial::TextForTeX
- Tioga::Tutorial::UsingRuby
- Tioga::Using_Paths
- Tioga::X_and_Y_Axes
- Dobjects
- Dobjects::Dtable
- Dobjects::Dvector
- Dobjects::Function
- Dobjects::MathEvaluator
- Flate
- TiogaDoc

No matching classes.

# Tioga::Flate

### Public Class Methods

compress(str) → string click to toggle source

Returns a compressed verion of str in a new string.

    VALUE do_compress(VALUE klass, VALUE str) {
       str = rb_String(str);
       unsigned char *ptr = (unsigned char *)RSTRING_PTR(str);
       long len = RSTRING_LEN(str);
       unsigned long new_len = (len * 11) / 10 + 100;
       unsigned char *new_ptr = ALLOC_N(unsigned char, new_len);
       if (flate_compress(new_ptr, &new_len, ptr, len) != Z_OK) {
          free(new_ptr);
          rb_raise(rb_eArgError, "Error in Flate.compress");
       }
       VALUE new_str = rb_str_new((char *)new_ptr, new_len);
       free(new_ptr);
       return new_str;
    }

expand(str) → string click to toggle source

Returns a decompressed verion of str in a new string. Assumes that str was compressed using `Flate.compress`.

    VALUE do_expand(VALUE klass, VALUE str) {
       str = rb_String(str);
       unsigned char *ptr = (unsigned char *)RSTRING_PTR(str);
       long len = RSTRING_LEN(str);
       unsigned long new_len = len * 4 + 100;
       unsigned char *new_ptr = ALLOC_N(unsigned char, new_len);
       if (flate_expand(&new_ptr, &new_len, ptr, len) != Z_OK) {
          free(new_ptr);
          rb_raise(rb_eArgError, "Error in Flate.expand");
       }
       VALUE new_str = rb_str_new((char *)new_ptr, new_len);
       free(new_ptr);
       return new_str;
    }

[Validate]

Generated with the Darkfish Rdoc Generator 2.