class MusicBrainz::Base

Public Class Methods

get(method, mbid, query) click to toggle source
# File lib/musicbrainz/base.rb, line 4
def self.get(method, mbid, query)
  if method=='search'

    includes="?query=#{query}" unless query==[]
  else
    includes="?inc=#{query}" unless query==[]
  end
  path="/ws/2/#{method}/#{mbid}#{includes}"
  uri_host="musicbrainz.org"
  uri_port="80"
  http = Net::HTTP.new(uri_host, uri_port).get(path)
  response = http.response.code
  body = http.response.body

  body=Hash.from_xml(body)
  if response=="200"
    return body
  else
    return false
  end


end
get_query_path(method, query) click to toggle source
# File lib/musicbrainz/base.rb, line 28
def self.get_query_path(method, query)

  inc="?query=#{query}"
  path="/ws/2/#{method}#{inc}"
  uri_host="musicbrainz.org"
  uri_port="80"
  puts path
  http = Net::HTTP.new(uri_host, uri_port).get(path)
  response = http.response.code
  body = http.response.body

  body=Hash.from_xml(body)
  if response=="200"
    return body
  else
    return false
  end

end