Permalink
Browse files

Merge branch 'enhancements'

  • Loading branch information...
2 parents f9b6735 + 781b98d commit 86f92090a7d81492490c1cdf0a58d5ed84ef0266 @mojodna mojodna committed Dec 1, 2008
Showing with 23 additions and 0 deletions.
  1. +9 −0 lib/xmpp4r/pubsub/children/items.rb
  2. +14 −0 lib/xmpp4r/pubsub/children/publish.rb
@@ -10,6 +10,7 @@ module PubSub
# Items
# a collection of Items
class Items < XMPPElement
+ include Enumerable
name_xmlns 'items', NS_PUBSUB
def node
@@ -30,6 +31,14 @@ def max_items
def max_items=(mymaxitems)
attributes['max_items'] = mymaxitems
end
+
+ def items
+ get_elements("item")
+ end
+
+ def each(&block)
+ items.each(&block)
+ end
end
##
@@ -13,7 +13,21 @@ module PubSub
# A <publish> XMPP element, see example 1 in
# http://www.xmpp.org/extensions/xep-0060.html#intro-howitworks
class Publish < XMPPElement
+ include Enumerable
name_xmlns 'publish', NS_PUBSUB
+
+ ##
+ # support for enumerating <item> elements
+ def each(&block)
+ items.each(&block)
+ end
+
+ ##
+ # return child <item> elements
+ def items
+ get_elements("item")
+ end
+
##
# return the node for this publication
def node

0 comments on commit 86f9209

Please sign in to comment.