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.



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

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)
end

Instance Attribute Details

#blog_idObject (readonly)

Returns the value of attribute blog_id.



10
11
12
# File 'lib/metaweblog/client.rb', line 10

def blog_id
  @blog_id
end

#clientObject (readonly)

Returns the value of attribute client.



10
11
12
# File 'lib/metaweblog/client.rb', line 10

def client
  @client
end

#passwordObject (readonly)

Returns the value of attribute password.



10
11
12
# File 'lib/metaweblog/client.rb', line 10

def password
  @password
end

#proxyObject (readonly)

Returns the value of attribute proxy.



10
11
12
# File 'lib/metaweblog/client.rb', line 10

def proxy
  @proxy
end

#uriObject (readonly)

Returns the value of attribute uri.



10
11
12
# File 'lib/metaweblog/client.rb', line 10

def uri
  @uri
end

#usernameObject (readonly)

Returns the value of attribute username.



10
11
12
# File 'lib/metaweblog/client.rb', line 10

def username
  @username
end

Instance Method Details

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



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

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

#get(post_id) ⇒ Object



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

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

#post(post, publish = true) ⇒ Object



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

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

#recent_posts(n = 10) ⇒ Object



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

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