Sha256: d31fef53f0f6ce0458e14015916cdb0191ea8977e56c56e6698bc5b30c67d7a1

Contents?: true

Size: 788 Bytes

Versions: 1

Compression:

Stored size: 788 Bytes

Contents

require 'net/http'

module Noip
  class Updater

    def initialize
      initialize_http_request
    end

    def update
      @response ||= http.request(request)
    end

  private

    attr_reader :http, :request, :response

    def initialize_http_request
      @http = Net::HTTP.new('dynupdate.no-ip.com')

      @request = Net::HTTP::Get.new(
        "/nic/update?hostname=#{credentials.host}&ip=#{remote_ip.address}",
        { 'User-Agent' => agent.user_agent }
      )
      @request.basic_auth(
        credentials.username,
        credentials.password
      )
    end

    def agent
      @agent ||= Noip::Agent.new
    end

    def remote_ip
      @remote_ip ||= Noip::RemoteIp.new
    end

    def credentials
      @credentials ||= Noip::Credentials.new
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
noip-0.1 lib/noip/updater.rb