Class: MetaWeblog::Client
- Inherits:
-
Object
- Object
- MetaWeblog::Client
- Defined in:
- lib/metaweblog/client.rb
Instance Attribute Summary collapse
-
#blog_id ⇒ Object
readonly
Returns the value of attribute blog_id.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#proxy ⇒ Object
readonly
Returns the value of attribute proxy.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #edit(post_id, post, publish = true) ⇒ Object
- #get(post_id) ⇒ Object
-
#initialize(uri, blog_id, username, password, proxy = nil) ⇒ Client
constructor
A new instance of Client.
- #post(post, publish = true) ⇒ Object
- #recent_posts(n = 10) ⇒ Object
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_id ⇒ Object (readonly)
Returns the value of attribute blog_id.
8 9 10 |
# File 'lib/metaweblog/client.rb', line 8 def blog_id @blog_id end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/metaweblog/client.rb', line 8 def client @client end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
8 9 10 |
# File 'lib/metaweblog/client.rb', line 8 def password @password end |
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
8 9 10 |
# File 'lib/metaweblog/client.rb', line 8 def proxy @proxy end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
8 9 10 |
# File 'lib/metaweblog/client.rb', line 8 def uri @uri end |
#username ⇒ Object (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 |