module CtGov

Constants

BASE_OPTIONS
BASE_URL
VERSION

Public Class Methods

find_by_nctid(nctid) click to toggle source
# File lib/ct_gov.rb, line 20
def self.find_by_nctid(nctid)
  uri = ::URI.parse("#{BASE_URL}/ct2/show/#{nctid}#{BASE_OPTIONS}")
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  
  request = Net::HTTP::Get.new(uri.request_uri)
  response = http.request(request)

  ClinicalTrial.new(Saxerator.parser(response.body).for_tag(:clinical_study).first) if response.code == "200"
end