---
product: Chilkat
product_version: 11.7.0
language: ckruby
language_label: Ruby
document: language guide
---
> Chilkat 11.7.0 · language=ckruby · this file: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/ckruby/guide.md`
> Class pages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/ckruby/classes/<Class>.md`

# Chilkat for Ruby — language guide — v11.7.0

## 1. Which Chilkat binding this is

This is the **Chilkat Ruby gem** (`require 'chilkat'`): classes `Chilkat::CkHttp`, `Chilkat::CkZip`, …, created with `Chilkat::CkHttp.new()`; properties through `get_Xxx()` / `put_Xxx(...)`; string-producing methods also have a lowercase-initial form returning the string. This is the only Ruby binding.

## 2. Install and requirements

```
gem install chilkat
```

Gems exist per OS and CPU (Windows, Linux, Alpine, macOS) and Ruby version; see [https://www.chilkatsoft.com/ruby.asp](https://www.chilkatsoft.com/ruby.asp).

## 3. Unlocking and object creation

```ruby
require 'chilkat'

# Required once per process, before any other Chilkat object. Any string unlocks a 30-day trial.
glob = Chilkat::CkGlobal.new()
success = glob.UnlockBundle("Anything for 30-day trial")
if (success != true)
    print glob.lastErrorText() + "\n"
    exit
end

http = Chilkat::CkHttp.new()
```

- Unlocking only sets a flag in memory: no license files, no network call, so the call is repeated each time the program runs. Extra calls are harmless no-ops; the `Global` object can be discarded afterwards.
- If a program forgets to unlock, Chilkat runs in trial mode and stops working when the trial expires — always include the call, and use the purchased unlock code in production.
- `UnlockBundle` unlocks every class; per-class `UnlockComponent` methods exist only in old code.

## 4. Error model

Chilkat methods **do not raise**. The note under each method on the class page says how it reports failure: a status method returns `false`; the lowercase-initial string form returns `nil` on failure while the uppercase form fills a `Chilkat::CkString` and returns a status; object-returning methods return `nil`; for an int result check `get_LastMethodSuccess()`. `lastErrorText()` holds the diagnostic in every case.

Literals in Ruby: true is `true`, false is `false`, null/none is `nil`.

## 5. Strings, bytes and encodings

- Strings are Ruby strings (UTF-8); a `charset` argument names the encoding of the *bytes* being produced or read.
- Binary data goes through `Chilkat::CkByteData` / `Chilkat::CkBinData` objects (`Bd` methods); `getBytes()` returns a binary string.
- Methods with `2`/`3` suffixes or `Quick*` prefixes are distinct members, not overloads.

## 6. Object lifetime and threading

Objects are released by Ruby's garbage collector.

A Chilkat object may be used from any thread, but **one object must not be used by two threads at the same time**: create one object per thread or protect it with a lock. Objects are independent — there is no shared global state other than the unlock flag and the few `Global` settings.

## 7. Progress callbacks and async

This binding has **no progress callbacks**. For progress, percent-done or cancellation, use the `*Async` variant of a method (every method with an "Async variant" line on its class page has one). `XAsync` takes the same arguments, returns a `Task` immediately, and the result is read from the task after it finishes: run it, poll `Finished` (or wait), then `GetResultBool` / `GetResultString` / `GetResultBytes` etc.; `PercentDone` and `Cancel` are on the task. No new Async methods are added from 11.7.0 on.

## 8. Common mistakes an AI makes with this binding

1. Using attribute syntax (`http.port = 443`) — in this binding it is `http.put_Port(443)`.
2. Writing `Chilkat::Http` (no `Ck`) — here it is `Chilkat::CkHttp`.
3. Omitting `Global.UnlockBundle` (the program runs in trial mode and stops working after 30 days).
4. Inventing members by analogy with other libraries. If a member is not on the class page, it does not exist — look it up rather than guessing.
5. Using deprecated members that older examples still show. The class page lists each one with its replacement; `deprecated.md` lists them all.
6. Ignoring the failure path. Every Chilkat method reports failure (see each method's note); `LastErrorText` says why, and printing it is the first debugging step.
7. Using one Chilkat object from two threads at the same time. Create one object per thread, or protect it with a lock.

## 9. Instructions block for coding agents

Paste into `CLAUDE.md`, `.cursor/rules`, or Copilot instructions:

```
This project uses Chilkat 11.7.0 from Ruby (gem chilkat; classes Chilkat::CkHttp, ...).
- Reference: https://www.chilkatsoft.com/ai-docs/v/11.7.0/ckruby/ — read guide.md once, then classes/<Class>.md for each class used.
- Call Chilkat::CkGlobal.new().UnlockBundle(...) once at startup.
- Properties are methods: put_Xxx(v) to set, get_Xxx() to read.
- Chilkat methods never raise: check the false/nil result and print obj.lastErrorText().
- Never use a member that is not on the class page; never use members listed as deprecated.
```

## 10. Classes

[Class index for Ruby](https://www.chilkatsoft.com/ai-docs/v/11.7.0/ckruby/index.md)
