Class: WpRpc::Category
- Inherits:
-
Object
- Object
- WpRpc::Category
- Defined in:
- lib/wp_rpc/category.rb
Instance Attribute Summary collapse
-
#category_id ⇒ Object
readonly
Returns the value of attribute category_id.
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rss_url ⇒ Object
readonly
Returns the value of attribute rss_url.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}, options = {}) ⇒ Category
constructor
A new instance of Category.
- #save ⇒ Object
- #slug ⇒ Object
- #to_xmlrpc_struct ⇒ Object
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ Category
Returns a new instance of Category.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/wp_rpc/category.rb', line 6 def initialize(attributes = {}, = {}) @id = attributes[:id] @category_id = attributes[:category_id] || 0 @description = attributes[:description] @name = attributes[:name] @url = attributes[:url] @rss_url = attributes[:rss_url] @slug = attributes[:slug] @conn = [:conn] end |
Instance Attribute Details
#category_id ⇒ Object (readonly)
Returns the value of attribute category_id.
4 5 6 |
# File 'lib/wp_rpc/category.rb', line 4 def category_id @category_id end |
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
4 5 6 |
# File 'lib/wp_rpc/category.rb', line 4 def conn @conn end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
4 5 6 |
# File 'lib/wp_rpc/category.rb', line 4 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/wp_rpc/category.rb', line 4 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/wp_rpc/category.rb', line 4 def name @name end |
#rss_url ⇒ Object (readonly)
Returns the value of attribute rss_url.
4 5 6 |
# File 'lib/wp_rpc/category.rb', line 4 def rss_url @rss_url end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'lib/wp_rpc/category.rb', line 4 def url @url end |
Class Method Details
.new_from_xmlrpc(attributes, options = {}) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/wp_rpc/category.rb', line 17 def self.new_from_xmlrpc(attributes, = {}) self.new( { :id => attributes['categoryId'], :category_id => attributes['parentId'], :description => attributes['description'], :name => attributes['categoryName'], :url => attributes['htmlUrl'], :rss_url => attributes['rssUrl'] }, ) end |
Instance Method Details
#save ⇒ Object
24 25 26 |
# File 'lib/wp_rpc/category.rb', line 24 def save @id = conn.call 'wp.newCategory', conn.blog_id, conn.username, conn.password, to_xmlrpc_struct end |
#slug ⇒ Object
32 33 34 |
# File 'lib/wp_rpc/category.rb', line 32 def slug @slug ||= @name.to_s.downcase.strip.gsub(/\s/, '-') end |
#to_xmlrpc_struct ⇒ Object
28 29 30 |
# File 'lib/wp_rpc/category.rb', line 28 def to_xmlrpc_struct { "name" => name, "slug" => slug, "parent_id" => category_id, "description" => description.to_s } end |