Class: Hatena::Keyword::Service

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

Overview

Service

Direct Known Subclasses

Link, Retrieve

Instance Method Summary collapse

Constructor Details

#initialize(string, options = {}) ⇒ Service

Returns a new instance of Service.



31
32
33
34
35
# File 'lib/hatena/keyword.rb', line 31

def initialize(string, options = {})
  @string  = NKF.nkf('-w', string.to_s)
  @options = options
  @result  = nil
end

Instance Method Details

#executeObject



37
38
39
40
41
42
43
44
45
# File 'lib/hatena/keyword.rb', line 37

def execute
  server = XMLRPC::Client.new2('http://d.hatena.ne.jp/xmlrpc')
  method = 'hatena.setKeywordLink'

  hash = default_options
  hash.delete(:body)
  logger.debug "#{self.class.name}(%s, %s)" % [method, hash.inspect]
  @result = server.call(method, default_options)
end