Sha256: 009dc2ef843a33b866e4b3b15e97e0d3c28c6acdf60bca5667f606ccc099109f

Contents?: true

Size: 519 Bytes

Versions: 1

Compression:

Stored size: 519 Bytes

Contents

require "net/https"

module Snitcher

  class Snitch
    attr_reader :token

    def initialize(token)
      @token = token
    end

    def checkin
      http = Net::HTTP.new("nosnch.in", 443)
      http.use_ssl = true

      response = http.request(Net::HTTP::Get.new("/#{@token}"))
      response.code_type == Net::HTTPOK
    end
  end

  class << self
    def by_token(token)
      Snitch.new(token)
    end

    def checkin(token)
      by_token(token).checkin
    end
    alias_method :snitch, :checkin
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
snitcher-0.1.0 lib/snitcher.rb