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.
8 9 10 11 12 13 14 15 16 |
# File 'lib/metaweblog/client.rb', line 8 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.
6 7 8 |
# File 'lib/metaweblog/client.rb', line 6 def blog_id @blog_id end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/metaweblog/client.rb', line 6 def client @client end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
6 7 8 |
# File 'lib/metaweblog/client.rb', line 6 def password @password end |
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
6 7 8 |
# File 'lib/metaweblog/client.rb', line 6 def proxy @proxy end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'lib/metaweblog/client.rb', line 6 def uri @uri end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
6 7 8 |
# File 'lib/metaweblog/client.rb', line 6 def username @username end |
Instance Method Details
#edit(post_id, post, publish = true) ⇒ Object
26 27 28 |
# File 'lib/metaweblog/client.rb', line 26 def edit(post_id, post, publish=true) client.call('metaWeblog.editPost', post_id, username, password, post.to_h, publish) end |
#get(post_id) ⇒ Object
18 19 20 |
# File 'lib/metaweblog/client.rb', line 18 def get(post_id) client.call('metaWeblog.getPost', post_id, username, password) end |
#post(post, publish = true) ⇒ Object
22 23 24 |
# File 'lib/metaweblog/client.rb', line 22 def post(post, publish=true) client.call('metaWeblog.newPost', blog_id, username, password, post.to_h, publish) end |
#recent_posts(n = 10) ⇒ Object
30 31 32 |
# File 'lib/metaweblog/client.rb', line 30 def recent_posts(n=10) client.call('metaWeblog.getRecentPosts', blog_id, username, password, n) end |