Class: Google::Blogsearch::Ping

Inherits:
Object
  • Object
show all
Defined in:
lib/google-blogsearch-pings.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, feed_url, options = {}) ⇒ Ping

Returns a new instance of Ping.



8
9
10
11
12
13
# File 'lib/google-blogsearch-pings.rb', line 8

def initialize(name, feed_url, options = {})
  @name, @feed_url = name, feed_url
  @site_url   = options.delete(:site)   || infer_url(feed_url)
  @update_url = options.delete(:update) || options.delete(:updated) || infer_url(feed_url)
  self.tags   = options.delete(:tags)   || []
end

Instance Attribute Details

#feed_urlObject

Returns the value of attribute feed_url.



6
7
8
# File 'lib/google-blogsearch-pings.rb', line 6

def feed_url
  @feed_url
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/google-blogsearch-pings.rb', line 6

def name
  @name
end

#site_urlObject

Returns the value of attribute site_url.



6
7
8
# File 'lib/google-blogsearch-pings.rb', line 6

def site_url
  @site_url
end

#tagsObject

Returns the value of attribute tags.



6
7
8
# File 'lib/google-blogsearch-pings.rb', line 6

def tags
  @tags
end

#update_urlObject

Returns the value of attribute update_url.



6
7
8
# File 'lib/google-blogsearch-pings.rb', line 6

def update_url
  @update_url
end

Instance Method Details

#ping!Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/google-blogsearch-pings.rb', line 15

def ping!
  server = XMLRPC::Client.new2("http://blogsearch.google.com/ping/RPC2")
  if tags.length == 0
    ok, param = server.call2("weblogUpdates.extendedPing", name, site_url, update_url, feed_url)
  else
    ok, param = server.call2("weblogUpdates.extendedPing", name, site_url, update_url, feed_url, tags_param)
  end
  
  if ok
    error, message = param['flerror'], param['message']
    raise message if error
    message
  else
    raise "#{param.faultString} (#{param.faultCode})"
  end
end

#tags_paramObject



32
33
34
# File 'lib/google-blogsearch-pings.rb', line 32

def tags_param
  tags.join("|")
end