Class: Wordpressto::Category
- Inherits:
-
Object
- Object
- Wordpressto::Category
- Defined in:
- lib/wordpressto/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.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/wordpressto/category.rb', line 5 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.
3 4 5 |
# File 'lib/wordpressto/category.rb', line 3 def category_id @category_id end |
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
3 4 5 |
# File 'lib/wordpressto/category.rb', line 3 def conn @conn end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/wordpressto/category.rb', line 3 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/wordpressto/category.rb', line 3 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/wordpressto/category.rb', line 3 def name @name end |
#rss_url ⇒ Object (readonly)
Returns the value of attribute rss_url.
3 4 5 |
# File 'lib/wordpressto/category.rb', line 3 def rss_url @rss_url end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/wordpressto/category.rb', line 3 def url @url end |
Class Method Details
.new_from_xmlrpc(attributes, options = {}) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/wordpressto/category.rb', line 16 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
23 24 25 |
# File 'lib/wordpressto/category.rb', line 23 def save @id = conn.call 'wp.newCategory', conn.blog_id, conn.username, conn.password, to_xmlrpc_struct end |
#slug ⇒ Object
31 32 33 |
# File 'lib/wordpressto/category.rb', line 31 def slug @slug ||= @name.to_s.downcase.strip.gsub(/\s/, '-') end |
#to_xmlrpc_struct ⇒ Object
27 28 29 |
# File 'lib/wordpressto/category.rb', line 27 def to_xmlrpc_struct { "name" => name, "slug" => slug, "parent_id" => category_id, "description" => description.to_s } end |