- README

- Top Level Namespace
- ArgumentError
- Array
- Atomic
- Base64
  - Error
- Benchmark
  - BM
    - Job
    - Tms
  - IPS
    - Entry
    - Job
- BigFloat
- BigInt
- BigRational
- BitArray
- Bool
- Box
- Bytes
- Channel
  - Buffered
  - ClosedError
  - ReceiveAction
  - SelectAction
  - SendAction
  - Unbuffered
- Char
  - Reader
- Class
- Colorize
  - Object
  - ObjectExtensions
- Comparable
- Complex
- Concurrent
  - CanceledError
- Crypto
  - Bcrypt
    - Error
    - Password
  - Blowfish
  - MD5
    - Context
  - Subtle
- CSV
  - Builder
    - Row
  - Error
  - Lexer
  - MalformedCSVError
  - Parser
  - Row
  - Token
    - Kind
- Debug
  - DWARF
    - LineNumbers
      - Register
      - Row
      - Sequence
    - LNE
    - LNS
  - ELF
    - Endianness
    - Error
    - Ident
    - Klass
    - Machine
    - OSABI
    - SectionHeader
      - Flags
      - Type
    - Type
- Deque
- Digest
  - SHA1
- Dir
- DivisionByZero
- DL
- ECR
- Enum
- Enumerable
  - EmptyError
- ENV
- Errno
- Exception
- Fiber
- File
  - Stat
- FileUtils
- Float
  - Primitive
- Float32
- Float64
- GC
  - Stats
- Hash
- HTML
- HTTP
  - Client
    - BodyType
    - Response
  - ComputedContentTypeHeader
  - Cookie
  - Cookies
  - DeflateHandler
  - ErrorHandler
  - Handler
    - Proc
  - Headers
  - LogHandler
  - Params
    - Builder
  - Request
  - Server
    - Context
    - RequestProcessor
    - Response
  - StaticFileHandler
    - DirectoryListing
  - WebSocket
  - WebSocketHandler
- Indexable
- IndexError
- INI
- Int
  - Primitive
  - Signed
  - Unsigned
- Int16
- Int32
- Int64
- Int8
- InvalidByteSequenceError
- IO
  - Buffered
  - ByteFormat
    - BigEndian
    - LittleEndian
    - NetworkEndian
    - SystemEndian
  - Delimited
  - EncodingOptions
  - EOFError
  - Error
  - FileDescriptor
  - Hexdump
  - Memory
  - MultiWriter
  - Seek
  - Sized
  - Timeout
- IPSocket
- Iterable
- Iterator
  - IteratorWrapper
  - Stop
- JSON
  - Any
  - ArrayBuilder
  - Builder
  - Error
  - Lexer
  - ObjectBuilder
  - ParseException
  - Parser
  - PrettyWriter
  - PullParser
  - Token
  - Type
- KeyError
- Levenshtein
  - Finder
- LLVM
  - ABI
    - AArch64
    - ArgKind
    - ArgType
    - ARM
    - FunctionType
    - X86
    - X86_64
      - RegClass
  - AtomicOrdering
  - AtomicRMWBinOp
  - Attribute
  - BasicBlock
  - BasicBlockCollection
  - Builder
  - CallConvention
  - CodeGenFileType
  - CodeGenOptLevel
  - CodeModel
  - Context
  - DIBuilder
  - DwarfTag
  - DwarfTypeEncoding
  - Function
  - FunctionCollection
  - FunctionPassManager
    - Runner
  - GenericValue
  - GlobalCollection
  - InstructionCollection
  - IntPredicate
  - JITCompiler
  - Linkage
  - MemoryBuffer
  - Module
  - ModulePassManager
  - ParameterCollection
  - PassManagerBuilder
  - PassRegistry
  - PhiTable
  - RealPredicate
  - RelocMode
  - Target
  - TargetData
  - TargetMachine
  - Type
    - Kind
  - Value
  - ValueMethods
  - VerifierFailureAction
- Logger
  - Formatter
  - Severity
- Markdown
  - HTMLRenderer
  - Parser
    - PrefixHeader
    - UnorderedList
  - Renderer
- Math
- MemoryIO
- Mutex
- NamedTuple
- Nil
- Number
  - Primitive
- OAuth
  - AccessToken
  - Consumer
  - Error
  - RequestToken
- OAuth2
  - AccessToken
    - Bearer
    - Mac
  - Client
  - Error
  - Session
- Object
- OpenSSL
  - Digest
    - Error
    - UnsupportedError
  - DigestBase
  - Error
  - HMAC
  - MD5
  - SHA1
  - SSL
    - Context
      - Client
      - Server
    - Error
    - ErrorType
    - Modes
    - Options
    - Socket
      - Client
      - Server
    - VerifyMode
    - X509VerifyFlags
  - X509
    - Certificate
    - Extension
    - Name
- OptionParser
  - Exception
  - InvalidOption
  - MissingOption
- PartialComparable
- Pointer
  - Appender
- PrettyPrint
- Proc
- Process
  - Env
  - Status
  - Stdio
  - Tms
- Random
  - MT19937
- Range
- Readline
  - CompletionProc
  - KeyBindingProc
- Reference
- Regex
  - MatchData
  - Options
- SecureRandom
- Set
- Signal
- Slice
- Socket
  - Address
  - Addrinfo
  - Error
  - Family
  - IPAddress
  - Protocol
  - Server
  - Type
  - UNIXAddress
- Spec
  - Expectations
  - Methods
  - ObjectExtensions
- StaticArray
- String
  - Builder
  - RawConverter
- StringPool
- StringScanner
- Struct
- Symbol
- System
- TCPServer
- TCPSocket
- Tempfile
- Termios
  - AttributeSelection
  - BaudRate
  - ControlMode
  - InputMode
  - LineControl
  - LocalMode
  - OutputMode
- Time
  - DayOfWeek
  - EpochConverter
  - EpochMillisConverter
  - Format
    - Error
  - Kind
  - MonthSpan
  - Span
- Tuple
- TypeCastError
- UDPSocket
- UInt16
- UInt32
- UInt64
- UInt8
- Unicode
  - CaseOptions
- Union
- UNIXServer
- UNIXSocket
- URI
  - Error
- Value
- XML
  - Attributes
  - AttributeType
  - Error
  - HTMLParserOptions
  - Namespace
  - Node
  - NodeSet
  - ParserOptions
  - Reader
  - SaveOptions
  - Type
  - XPathContext
- YAML
  - Any
  - Emitter
  - Error
  - EventKind
  - ParseException
  - Parser
  - PullParser
  - Type
- Zlib
  - Deflate
  - Error
  - Inflate

# class Zlib::Deflate

- Zlib::Deflate
- Reference
- Object

## Overview

A write-only `IO` object to compress data in zlib or gzip format.

Instances of this class wrap another IO object. When you write to this instance, it compresses the data and writes it to the underlying IO.

Note: unless created with a block, `#close` must be invoked after all data has been written to a Zlib::Deflate instance.

### Example: compress a file

    require "zlib"

    File.open("./file.txt", "r") do |input_file|
      File.open("./file.gzip", "w") do |output_file|
        Zlib::Deflate.gzip(output_file) do |deflate|
          IO.copy(input_file, deflate)
        end
      end
    end

See also: `Zlib::Inflate` for decompressing data.

## Included Modules

- IO

## Defined in:

## Class Method Summary

- .gzip(output, sync_close : Bool = false) : self

  Creates an instance of Zlib::Deflate for the gzip format.

- .gzip(output, sync_close : Bool = false, &block)

  Creates an instance of Zlib::Deflate for the gzip format, yields it to the given block, and closes it at its end.

- .new(output : IO, level = LibZ::DEFAULT_COMPRESSION, wbits = LibZ::MAX_BITS, mem_level = LibZ::DEF_MEM_LEVEL, strategy = LibZ::Strategy::DEFAULT_STRATEGY, sync_close : Bool = false)

  Creates an instance of Zlib::Deflate.

- .new(output : IO, level = LibZ::DEFAULT_COMPRESSION, wbits = LibZ::MAX_BITS, mem_level = LibZ::DEF_MEM_LEVEL, strategy = LibZ::Strategy::DEFAULT_STRATEGY, sync_close : Bool = false, &block)

  Creates an instance of Zlib::Deflate, yields it to the given block, and closes it at its end.

## Instance Method Summary

- #close

  Closes this IO.

- #closed? : Bool

  Returns `true` if this IO is closed.

- #flush

  See `IO#flush`.

- #read(slice : Bytes)

  Always raises: this is a write-only IO.

- #sync_close=(sync_close : Bool)

  If `sync_close` is true, closing this IO will close the underlying IO.

- #sync_close? : Bool

  If `sync_close` is true, closing this IO will close the underlying IO.

- #write(slice : Bytes)

  See `IO#write`.

### Instance methods inherited from module `IO`

<<(obj) : self <<, close close, closed? closed?, each_byte
each_byte(&block) each_byte, each_char(&block)
each_char each_char, each_line(*args, **options, &block)
each_line(*args, **options) each_line, encoding : String encoding, flush flush, gets(chomp = true) : String?
gets(delimiter : String, chomp = false) : String?
gets(delimiter : Char, chomp = false) : String?
gets(delimiter : Char, limit : Int, chomp = false) : String?
gets(limit : Int, chomp = false) : String? gets, gets_to_end : String gets_to_end, print(obj) : Nil
print(*objects : _) : Nil print, printf(format_string, *args) : Nil
printf(format_string, args : Array | Tuple) : Nil printf, puts(*objects : _) : Nil
puts(string : String) : Nil
puts(obj) : Nil
puts : Nil puts, read(slice : Bytes) read, read_byte : UInt8? read_byte, read_bytes(type, format : IO::ByteFormat = IO::ByteFormat::SystemEndian) read_bytes, read_char : Char? read_char, read_fully(slice : Bytes) read_fully, read_fully?(slice : Bytes) read_fully?, read_line(*args, **options) : String? read_line, read_utf8(slice : Bytes) read_utf8, read_utf8_byte read_utf8_byte, rewind rewind, set_encoding(encoding : String, invalid : Symbol? = nil) set_encoding, skip(bytes_count : Int) : Nil skip, tty? : Bool tty?, write(slice : Bytes) : Nil write, write_byte(byte : UInt8) write_byte, write_bytes(object, format : IO::ByteFormat = IO::ByteFormat::SystemEndian) write_bytes, write_utf8(slice : Bytes) write_utf8

### Class methods inherited from module `IO`

copy(src, dst, limit : Int)
copy(src, dst) copy, pipe(read_blocking = false, write_blocking = false)
pipe(read_blocking = false, write_blocking = false, &block) pipe, select(read_ios, write_ios, error_ios, timeout_sec : LibC::TimeT | Int | Float?)
select(read_ios, write_ios = nil, error_ios = nil) select

### Instance methods inherited from module `JSON::Builder`

json_array(&block) json_array, json_object(&block) json_object

### Instance methods inherited from class `Reference`

==(other : self)
==(other) ==, dup dup, hash hash, inspect(io : IO) : Nil inspect, object_id : UInt64 object_id, pretty_print(pp) : Nil pretty_print, same?(other : Reference)
same?(other : Nil) same?, to_s(io : IO) : Nil to_s

### Class methods inherited from class `Reference`

new new

### Instance methods inherited from class `Object`

!=(other) !=, !~(other) !~, ==(other) ==, ===(other : JSON::Any)
===(other : YAML::Any)
===(other) ===, =~(other) =~, class class, dup dup, hash hash, inspect(io : IO)
inspect inspect, itself itself, not_nil! not_nil!, pretty_inspect(width = 79, newline = "\n", indent = 0) : String pretty_inspect, pretty_print(pp : PrettyPrint) : Nil pretty_print, tap(&block) tap, to_json to_json, to_pretty_json(indent : String = " ")
to_pretty_json(io : IO, indent : String = " ") to_pretty_json, to_s
to_s(io : IO) to_s, to_yaml(io : IO)
to_yaml to_yaml, try(&block) try

### Class methods inherited from class `Object`

==(other : Class) ==, ===(other) ===, cast(other) : self cast, clone clone, dup dup, from_json(string_or_io, root : String) : self
from_json(string_or_io) : self from_json, from_yaml(string_or_io) : self from_yaml, hash hash, inspect(io) inspect, name : String name, nilable? nilable?, to_s(io) to_s, |(other : U.class) forall U |

## Class Method Detail

def self.gzip(output, sync_close : Bool = false) : self #

Creates an instance of Zlib::Deflate for the gzip format. `#close` must be invoked after all data has written.

def self.gzip(output, sync_close : Bool = false, &block) #

Creates an instance of Zlib::Deflate for the gzip format, yields it to the given block, and closes it at its end.

def self.new(output : IO, level = LibZ::DEFAULT_COMPRESSION, wbits = LibZ::MAX_BITS, mem_level = LibZ::DEF_MEM_LEVEL, strategy = LibZ::Strategy::DEFAULT_STRATEGY, sync_close : Bool = false) #

Creates an instance of Zlib::Deflate. `#close` must be invoked after all data has written.

def self.new(output : IO, level = LibZ::DEFAULT_COMPRESSION, wbits = LibZ::MAX_BITS, mem_level = LibZ::DEF_MEM_LEVEL, strategy = LibZ::Strategy::DEFAULT_STRATEGY, sync_close : Bool = false, &block) #

Creates an instance of Zlib::Deflate, yields it to the given block, and closes it at its end.

## Instance Method Detail

def close #

Closes this IO. Must be invoked after all data has been written.

def closed? : Bool #

Returns `true` if this IO is closed.

def flush #

See `IO#flush`.

def read(slice : Bytes) #

Always raises: this is a write-only IO.

def sync_close=(sync_close : Bool) #

If `sync_close` is true, closing this IO will close the underlying IO.

def sync_close? : Bool #

If `sync_close` is true, closing this IO will close the underlying IO.

def write(slice : Bytes) #

See `IO#write`.