class UUIDAPI
Public Class Methods
new(region)
click to toggle source
# File lib/mcapi-uuid.rb, line 9 def initialize(region) @@region = region end
Public Instance Methods
get_region()
click to toggle source
# File lib/mcapi-uuid.rb, line 17 def get_region puts @@region end
get_username(uuid)
click to toggle source
# File lib/mcapi-uuid.rb, line 31 def get_username(uuid) response = open('http://' + @@region + '.mc-api.net/v3/name/' + format_uuid(uuid)).read json = JSON.parse(response) if json['name'].is_a? String return json['name'] else return nil end end
get_uuid(username)
click to toggle source
# File lib/mcapi-uuid.rb, line 21 def get_uuid(username) response = open('http://' + @@region + '.mc-api.net/v3/uuid/' + username).read json = JSON.parse(response) if json['uuid'].is_a? String return json['uuid'] else return nil end end
set_region(region)
click to toggle source
# File lib/mcapi-uuid.rb, line 13 def set_region(region) @@region = region end
Private Instance Methods
format_uuid(uuid)
click to toggle source
# File lib/mcapi-uuid.rb, line 42 def format_uuid(uuid) if !uuid.is_a? String return nil end if uuid.length == 32 return uuid else uuid.delete! '-' if uuid.length == 32 return uuid else return nil end end end