Sha256: d32d09aefb41a6522d5c66bac0c6c4803d534cef2519642290d8067443be9dd9

Contents?: true

Size: 668 Bytes

Versions: 2

Compression:

Stored size: 668 Bytes

Contents

module QuakeliveApi
  module Parser
    class Base
      def initialize(document)
        @document = document
      end

      def invalid_player?
        document.css('p.tc').text =~ /The requested player could not be found or is not yet active/i
      end

      def request_error?
        document.css('#sorry_content p:first-child').text =~ /An error has occurred while handling your request/
      end

      private

      attr_reader :document

      def selectors
        raise NotImplementedError
      end

      def selector(name)
        selectors.fetch(name)
      end

      def to_integer(val)
        val.gsub(',','').to_i
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
quakelive_api-0.1.2 lib/quakelive_api/parser/base.rb
quakelive_api-0.1.1 lib/quakelive_api/parser/base.rb