Class: BlogPingingService::YahooRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/blog-pinging-service.rb

Constant Summary collapse

SERVICE_URI =
"http://search.yahooapis.com/SiteExplorerService/V1/ping"

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ YahooRequest

Returns a new instance of YahooRequest.



40
41
42
43
44
# File 'lib/blog-pinging-service.rb', line 40

def initialize(uri)
  @params      = {
    'sitemap' => uri,
  }
end

Instance Method Details

#performObject



54
55
56
57
58
59
60
61
# File 'lib/blog-pinging-service.rb', line 54

def perform
  c = Curl::Easy.new("#{SERVICE_URI}?#{query_string}") do |curl|
    curl.verbose = true
  end
  c.perform
  
  return c.body_str == 'Thanks for the ping.'
end

#query_stringObject



46
47
48
49
50
51
52
# File 'lib/blog-pinging-service.rb', line 46

def query_string
  elements = []
  @params.keys.size.times do |i|
    elements << "#{@params.keys[i]}=#{CGI::escape(@params.values[i])}"
  end
  elements.join('&')
end