Class: Wordpressto::CategoryCollection
- Includes:
- Enumerable
- Defined in:
- lib/wordpressto/category_collection.rb
Instance Method Summary collapse
- #[](i) ⇒ Object
- #all ⇒ Object
- #create(attributes) ⇒ Object
- #each ⇒ Object
-
#initialize(*args) ⇒ CategoryCollection
constructor
A new instance of CategoryCollection.
-
#load ⇒ Object
retrieve the categories via xmlrpc.
Methods inherited from Base
Constructor Details
#initialize(*args) ⇒ CategoryCollection
Returns a new instance of CategoryCollection.
6 7 8 |
# File 'lib/wordpressto/category_collection.rb', line 6 def initialize(*args) super(*args) end |
Instance Method Details
#[](i) ⇒ Object
23 24 25 |
# File 'lib/wordpressto/category_collection.rb', line 23 def [](i) all[i] end |
#all ⇒ Object
10 11 12 |
# File 'lib/wordpressto/category_collection.rb', line 10 def all @categories ||= load end |
#create(attributes) ⇒ Object
31 32 33 34 35 |
# File 'lib/wordpressto/category_collection.rb', line 31 def create(attributes) new_cat = Category.new(attributes, :conn => conn) new_cat.save new_cat end |
#each ⇒ Object
27 28 29 |
# File 'lib/wordpressto/category_collection.rb', line 27 def each all.each { |c| yield c } end |
#load ⇒ Object
retrieve the categories via xmlrpc
15 16 17 18 19 20 21 |
# File 'lib/wordpressto/category_collection.rb', line 15 def load cats = [] conn.call('wp.getCategories', conn.blog_id, conn.username, conn.password).each do |c| cats << Category.new_from_xmlrpc(c, :conn => conn) end @categories = cats end |