Là một dự án backend, ruby/rbs đã đạt 2.2k sao trên GitHub, ngôn ngữ Ruby. The type signature language for Ruby
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
RBS is a language to describe the structure of Ruby programs.
You can write down the definition of a class or module: methods defined in the class, instance variables and their types, and inheritance/mix-in relations.
It also allows declaring constants and global variables.
The following is a small example of RBS for a chat app.
module ChatApp
VERSION: String
class User
attr_reader login: String
attr_reader email: String
def initialize: (login: String, email: String) -> void
end
class Bot
attr_reader name: String
attr_reader email: String
attr_reader owner: User
def initialize: (name: String, owner: User) -> void
end
class Message
attr_reader id: String
attr_reader string: String
attr_reader from: User | Bot # `|` means union types: `#from` can be `User` or `Bot`
attr_reader reply_to: Message? # `?` means optional type: `#reply_to` can be `nil`
def initialize: (from: User | Bot, string: String) -> void
def reply: (from: User | Bot, string: String) -> Message
end
class Channel
attr_reader name: String
attr_reader messages: Array[Message]
attr_reader users: Array[User]
attr_reader bots: Array[Bot]
def initialize: (name: String) -> void
def each_member: () { (User | Bot) -> void } -> void # `{` and `}` means block.
| () -> Enumerator[User | Bot, void] # Method can be overloaded.
end
end
The Target Version
The standard library signatures targets the latest release of Ruby. (4.0 as of 2026.)
The library code targets non-EOL versions of Ruby. (>= 3.3 as of 2026.)
Installation
Install the rbs gem. $ gem install rbs from the command line, or add a line in your Gemfile.
gem "rbs"
CLI
The gem ships with the rbs command line tool to demonstrate what it can do and help develop RBS.
$ rbs version
$ rbs list
$ rbs ancestors ::Object
$ rbs methods ::Object
$ rbs method Object then
An end user of rbs will probably find rbs prototype the most useful. This command generates boilerplate signature declarations for ruby files. For example, say you have written the below ruby script.
# person.rb
class Person
attr_reader :name
attr_reader :contacts
def initialize(name:)
@name = name
@contacts = []
end
def speak
"I'm #{@name} and I love Ruby!"
end
end
Running prototype on the above will automatically generate
$ rbs prototype rb person.rb
class Person
@name: untyped
@contacts: untyped
attr_reader name: untyped
attr_reader contacts: untyped
def initialize: (name: untyped) -> void
def speak: () -> ::String
end
It prints signatures for all methods, classes, instance variables, and constants.
This is only a starting point, and you should edit the output to match your signature more accurately.
rbs prototype offers three options.
rb generates from just the available Ruby code
rbi generates from Sorbet RBI
runtime generates from runtime API (deprecated; see #2841)
Library
There are two important concepts, environment and definition.
An environment is a dictionary that keeps track of all declarations. What is the declaration associated with String class? An environment will give you the answer.
A definition gives you the detail of the class. What is the type of the return value of gsub method of the String class? The definition for String class knows the list of methods it provides and their types.
The following is a small code to retrieve the definition of the String#gsub method.
require "rbs"
loader = RBS::EnvironmentLoader.new()
# loader.add(path: Pathname("sig")) # Load .rbs files from `sig` directory
# loader.add(library: "logger") # Load logger library
environment = RBS::Environment.from_loader(loader).resolve_type_names
# ::String
string = RBS::TypeName.new(name: :String, namespace: RBS::Namespace.root)
# Class declaration for ::String
decl = environment.class_decls[string]
# Builder provides the translation from `declaration` to `definition`
builder = RBS::DefinitionBuilder.new(env: environment)
# Definition of instance of String
instance = builder.build_instance(string)
# Print the types of `gsub` method:
puts instance.methods[:gsub].method_types.join("\n")
# Outputs =>
# (::Regexp | ::string pattern, ::string replacement) -> ::String
# (::Regexp | ::string pattern, ::Hash[::String, ::String] hash) -> ::String
# (::Regexp | ::string pattern) { (::String match) -> ::_ToS } -> ::String
# (::Regexp | ::string pattern) -> ::Enumerator[::String, self]
# Definition of singleton of String
singleton = builder.build_singleton(string)
# No `gsub` method for String singleton
puts singleton.methods[:gsub]
Guides
Architecture
Core and standard library signature contribution guide
Writing signatures guide
Stdlib signatures guide
Syntax
RBS by Example
RBS collection
Using Data and Struct
Releasing a gem with RBS
Community
Here is a list of some places you can talk with active maintainers.
Ruby Discord Server (invite link) -- We have rbs channel in Ruby Discord server.
ruby-jp Slack Workspace (in Japanese) -- We have types channel in ruby-jp slack workspace.
gem_rbs_collection -- We have a repository of third-party RBS type definitions, for the case your dependency doesn't ship with RBS files.
Development
After checking out the repo, run bin/setup to install dependencies. Then, run bundle exec rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. Releases are cut by the Release gems workflow rather than from a working copy -- see docs/release.md.
C Code Formatting
This project uses clang-format to enforce consistent formatting of C code with a .clang-format configuration in the root directory.
ruby/rbs thuộc nhóm Backend trên TopGit, cùng 2 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về ruby/rbs ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/ruby/rbs là nguồn chính thức.
ruby/rbs có phải mã nguồn mở không?
TopGit chưa ghi nhận license cho ruby/rbs. Phần lớn repo public trên GitHub là mã nguồn mở, nhưng điều khoản khác nhau từng repo — mở file LICENSE để xác nhận.
ruby/rbs có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho ruby/rbs. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
ruby/rbs là gì?
ruby/rbs (ruby/rbs) là dự án Ruby trên GitHub. Theo mô tả gốc: The type signature language for Ruby
Vì sao ruby/rbs được xếp vào nhóm Backend?
TopGit xếp ruby/rbs vào nhóm Backend dựa trên GitHub topics và mô tả của repo (gắn thẻ: "ruby", "type-checking"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
Chưa chắc rbs có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về rbs.