<commit_before>require 'uri'
require 'net/http'

class Instapaper
  def initialize(username, password)
    @username = username
    @password = password
    @return_code = 0
  end

  def check_auth?
    execute_url_command(auth_url('authenticate'))
    return ( @return_code == "200" )
  end

  def add?(url)
    execute_url_command(auth_url("add") << "&url=#{url}")
    return ( @return_code == "201" )
  end
 
  def execute_url_command(url)
    command = URI.parse(url)
    Net::HTTP.start(command.host) do |http|
      @return_code = http.head(command.request_uri).code
    end
  end
  
  def return_code
    @return_code
  end

  private

  def auth_url(command)
    if @username.include?("@")
      "https://www.instapaper.com/api/#{command}/" << "?username=#{@username}&password=#{<PASSWORD>}"
    else
      "https://#{@username}:#{@password}@www.instapaper.com/api/#{command}/"
    end
  end
end<commit_msg>minor refactor<commit_after>require 'uri'
require 'net/http'

class Instapaper
  def initialize(username, password)
    @username = username
    @password = password
    @return_code = 0
  end

  def check_auth?
    execute_url_command(auth_url('authenticate'))
    return ( @return_code == "200" )
  end

  def add?(url)
    execute_url_command(auth_url("add") << "&url=#{url}")
    return ( @return_code == "201" )
  end
  
  def return_code
    @return_code
  end

  private
  
  def execute_url_command(url)
    command = URI.parse(url)
    Net::HTTP.start(command.host) do |http|
      @return_code = http.head(command.request_uri).code
    end
  end

  def auth_url(command)
    if @username.include?("@")
      "https://www.instapaper.com/api/#{command}/" << "?username=#{@username}&password=#{<PASSWORD>}"
    else
      "https://#{@username}:#{@password}@www.instapaper.com/api/#{command}/"
    end
  end
end
{'fraction_non_alphanumeric': 0.1539301310043668, 'fraction_numerical': 0.007641921397379912, 'mean_word_length': 3.5036855036855035, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7202566', 'n_tokens_mistral': 660, 'n_tokens_neox': 644, 'n_words': 116}