Sha256: 7abbf2edfa06b43eb5ccb12f87f78876ecb0257a8f121e1e6ee9a77058fab230

Contents?: true

Size: 963 Bytes

Versions: 4

Compression:

Stored size: 963 Bytes

Contents

require 'orkut/version'
require 'orkut/error'
require 'orkut/constants/internal_constants'

module Orkut
  class Client
    module Base
      
      DEFAULT_COUNT = 40

      DEFAULT_DATETIME_FORMAT = '%Y-%m-%dT%I:%M:%SZ'
      
      def default_headers
        return {
          Orkut::Constants::InternalConstants::CONTENT_TYPE => Orkut::Constants::InternalConstants::JSON_CONTENT_TYPE,
          Orkut::Constants::InternalConstants::ORKUT_CLIENT_LIB_HEADER => Orkut::Version.to_s
        }
      end
      
      def request_id
        @request_id = 0
        @request_id += 1
        @request_id
      end

      def format_datetime datetime
        if datetime.kind_of?(Time)
          return datetime.utc.strftime(DEFAULT_DATETIME_FORMAT)
        elsif datetime.kind_of?(String)
          return Time.at(datetime).utc.strftime(DEFAULT_DATETIME_FORMAT)
        else
          raise(Orkut::Error, 'Invalid datetime')
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
orkut-0.0.0.7 lib/orkut/client/base.rb
orkut-0.0.0.6 lib/orkut/client/base.rb
orkut-0.0.0.5 lib/orkut/client/base.rb
orkut-0.0.0.4 lib/orkut/client/base.rb