Sha256: 2a76ed43897832c0100bbd2d356b5b03d99a6808717ccfe6b08f1ccbb36fb0e0

Contents?: true

Size: 793 Bytes

Versions: 1

Compression:

Stored size: 793 Bytes

Contents

require 'open-uri'

module EveOnline
  # http://wiki.eve-id.net/APIv2_Server_ServerStatus_XML
  class ServerStatus < Base
    API_ENDPOINT = 'https://api.eveonline.com/Server/ServerStatus.xml.aspx'

    def current_time
      # TODO: time in "(GMT) Monrovia, Reykjavik".
      eveapi.fetch('currentTime')
    end

    def server_open?
      result.fetch('serverOpen') == 'True'
    end

    def online_players
      result.fetch('onlinePlayers').to_i
    end

    def cached_until
      # TODO: time in "(GMT) Monrovia, Reykjavik".
      eveapi.fetch('cachedUntil')
    end

    def version
      eveapi.fetch('@version').to_i
    end

    def result
      eveapi.fetch('result')
    end

    def eveapi
      response.fetch('eveapi')
    end

    def url
      API_ENDPOINT
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eve_online-0.2.0 lib/eve_online/server_status.rb