Class: Smarticus::DeliciousConnection

Inherits:
Object
  • Object
show all
Defined in:
lib/yummy.rb

Instance Method Summary collapse

Constructor Details

#initialize(user, pass) ⇒ DeliciousConnection

Returns a new instance of DeliciousConnection.



62
63
64
65
66
67
68
# File 'lib/yummy.rb', line 62

def initialize(user,pass)
  @user = user
  @pass = pass
  
  @http = Net::HTTP.new("api.del.icio.us", 443)
  @http.use_ssl = true
end

Instance Method Details

#get(options = {}) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/yummy.rb', line 70

def get(options={})
  body = ""
  params = parameterize_hash(options)
  path = "/v1/posts/get?" + params
  
  @http.start do |http|
    request = Net::HTTP::Get.new(path, {"User-Agent" => Smarticus::USER_AGENT})
    request.basic_auth(@user, @pass)
    response = @http.request(request)
    body = response.body
  end
  
  body
end