Class: MetaWeblog::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, blog_id, username, password, proxy = nil) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
15
16
17
18
# File 'lib/metaweblog/client.rb', line 10

def initialize(uri, blog_id, username, password, proxy = nil)
  @uri = uri
  @proxy = proxy
  @blog_id = blog_id
  @username = username
  @password = password
  @client = XMLRPC::Client.new2(@uri, @proxy)
  @client.http_header_extra = { 'Accept-Encoding' => 'identity' }
end

Instance Attribute Details

#blog_idObject (readonly)

Returns the value of attribute blog_id.



8
9
10
# File 'lib/metaweblog/client.rb', line 8

def blog_id
  @blog_id
end

#clientObject (readonly)

Returns the value of attribute client.



8
9
10
# File 'lib/metaweblog/client.rb', line 8

def client
  @client
end

#passwordObject (readonly)

Returns the value of attribute password.



8
9
10
# File 'lib/metaweblog/client.rb', line 8

def password
  @password
end

#proxyObject (readonly)

Returns the value of attribute proxy.



8
9
10
# File 'lib/metaweblog/client.rb', line 8

def proxy
  @proxy
end

#uriObject (readonly)

Returns the value of attribute uri.



8
9
10
# File 'lib/metaweblog/client.rb', line 8

def uri
  @uri
end

#usernameObject (readonly)

Returns the value of attribute username.



8
9
10
# File 'lib/metaweblog/client.rb', line 8

def username
  @username
end

Instance Method Details

#edit(post_id, post, publish = true) ⇒ Object



28
29
30
# File 'lib/metaweblog/client.rb', line 28

def edit(post_id, post, publish=true)
  client.call('metaWeblog.editPost', post_id, username, password, post.to_h, publish)
end

#get(post_id) ⇒ Object



20
21
22
# File 'lib/metaweblog/client.rb', line 20

def get(post_id)
  client.call('metaWeblog.getPost', post_id, username, password)
end

#post(post, publish = true) ⇒ Object



24
25
26
# File 'lib/metaweblog/client.rb', line 24

def post(post, publish=true)
  client.call('metaWeblog.newPost', blog_id, username, password, post.to_h, publish)
end

#recent_posts(n = 10) ⇒ Object



32
33
34
# File 'lib/metaweblog/client.rb', line 32

def recent_posts(n=10)
  client.call('metaWeblog.getRecentPosts', blog_id, username, password, n)
end