Method: Atom::Service#initialize
- Defined in:
- lib/atom/service.rb
#initialize(service_url = "", http = Atom::HTTP.new) ⇒ Service
retrieves and parses an Atom service document.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/atom/service.rb', line 27 def initialize(service_url = "", http = Atom::HTTP.new) super() @http = http return if service_url.empty? base = URI.parse(service_url) rxml = nil res = @http.get(base, "Accept" => "application/atomsvc+xml") res.validate_content_type(["application/atomsvc+xml"]) unless res.code == "200" raise Atom::HTTPException, "Unexpected HTTP response code: #{res.code}" end self.class.parse(res.body, base, self) end |