require 'stringio'

module QuoraNotify::CookieReaders
  class CookieIO < StringIO
    def next
      self.read(4)
    end

    def next_as_int
      self.next.unpack('l<')[0]
    end

    def read_as_flag
      case self.next_as_int
        when 0; ''
        when 1; 'Secure'
        when 4; 'HttpOnly'
        when 5; 'Secure: HttpOnly'
        else; 'Unknown'
      end
    end

    def read_as_date
      self.read(8).unpack('E')[0] + 978307200
    end
  end
end

require 'quora_notify/cookie_readers/cookie_reader'
require 'quora_notify/cookie_readers/firefox_cookie_reader'
require 'quora_notify/cookie_readers/safari_cookie_reader'
require 'quora_notify/cookie_readers/chrome_cookie_reader'
