Class: RCON::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/rcon/rcon.rb

Direct Known Subclasses

Minecraft, Source

Instance Method Summary collapse

Instance Method Details

#cvar(cvar_name) ⇒ Object

Convenience method to scrape input from cvar output and return that data. Returns integers as a numeric type if possible.

ex: rcon.cvar(“mp_friendlyfire”) => 1

NOTE: This file has not been updated since previous version. Please be aware there may be outstanding Ruby2 bugs



13
14
15
16
17
18
19
20
21
22
# File 'lib/rcon/rcon.rb', line 13

def cvar(cvar_name)
  response = command(cvar_name)
  match = /^.+?\s(?:is|=)\s"([^"]+)".*$/.match response
  match = match[1]
  if /\D/.match match
    return match
  else
    return match.to_i
  end
end