ruby-qstat

A wrapper gem for using QStat, a game server statistics tool, from Ruby. It launches the qstat command and returns the results — server lists fetched from master servers and status queries against individual game servers — as Ruby objects.

The requirements stated in the README are Ruby 1.9 and QStat 2.12.

Usage

gem install ruby-qstat

Examples from the README.

# fetch the server list from a master server
QStat.query_serverlist("hl2master.steampowered.com:27011", "stm", "left4dead2", maxping = 100)

# query the status of one server
QStat.query("xxx.yyy.zzz.qqq", "a2s")

# query the status of one server (server info only)
QStat.query_serverinfo("xxx.yyy.zzz.qqq", "a2s")

Internals

The library itself is a single file, lib/ruby-qstat.rb, and the API is provided as class methods on the QStat class (it cannot be instantiated). Launching the qstat command is centralized in a shared exec_cmd, and parsing splits into two paths depending on the output format.

Component diagram of ruby-qstat

The flow of fetching a server list (query_serverlist). It is built to cut qstat off as soon as a server exceeding maxping appears, and the truncated XML is handed to Nokogiri as-is for parsing.

Sequence diagram of query_serverlist

My own gem vrowser (a server browser library for HalfLife2-family games) is built on top of this gem. It is also used by the server browser published on my site (its listing data has been frozen since 2017).

🤖 This English version is machine-translated by AI.