ensl.org/lib/steamid.rb
2020-04-10 18:32:18 +03:00

12 lines
No EOL
307 B
Ruby

module SteamID
def self.to_steamID(steamid)
m = steamid.match(/^(STEAM_){0,1}([0-5]):([01]:\d+)$/)
return ((m[3].to_i * 2) + m[2].to_i) + 76561197960265728
end
def self.from_steamID64(sid)
y = sid.to_i - 76561197960265728
x = y % 2
return "0:%d:%d" % [x, (y - x).div(2)]
end
end