Sha256: 1db269f5acd8483fd876130dcdd37f75b911d68b033396f1128344ce0d434ba9

Contents?: true

Size: 763 Bytes

Versions: 1

Compression:

Stored size: 763 Bytes

Contents

module EveOnline
  module Server
    # https://eveonline-third-party-documentation.readthedocs.org/en/latest/xmlapi/server/serv_serverstatus.html
    class Status < BaseXML
      API_ENDPOINT = 'https://api.eveonline.com/Server/ServerStatus.xml.aspx'.freeze

      def as_json(*args)
        {
          current_time: current_time,
          cached_until: cached_until,
          server_open: server_open,
          online_players: online_players
        }
      end

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

      alias server_open? server_open

      def online_players
        @online_players ||= result.fetch('onlinePlayers').to_i
      end

      def url
        API_ENDPOINT
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eve_online-0.7.0 lib/eve_online/server/status.rb