Skip to content
This repository
Browse code

Merge branch 'enhancements'

  • Loading branch information...
commit 86f92090a7d81492490c1cdf0a58d5ed84ef0266 2 parents f9b6735 + 781b98d
Seth Fitzsimmons authored December 01, 2008
9  lib/xmpp4r/pubsub/children/items.rb
@@ -10,6 +10,7 @@ module PubSub
10 10
     # Items
11 11
     # a collection of Items
12 12
     class Items < XMPPElement
  13
+      include Enumerable
13 14
       name_xmlns 'items', NS_PUBSUB
14 15
 
15 16
       def node
@@ -30,6 +31,14 @@ def max_items
30 31
       def max_items=(mymaxitems)
31 32
         attributes['max_items'] = mymaxitems
32 33
       end
  34
+
  35
+      def items
  36
+        get_elements("item")
  37
+      end
  38
+
  39
+      def each(&block)
  40
+        items.each(&block)
  41
+      end
33 42
     end
34 43
 
35 44
     ##
14  lib/xmpp4r/pubsub/children/publish.rb
@@ -13,7 +13,21 @@ module PubSub
13 13
     # A <publish> XMPP element, see example 1 in
14 14
     # http://www.xmpp.org/extensions/xep-0060.html#intro-howitworks
15 15
     class Publish < XMPPElement
  16
+      include Enumerable
16 17
       name_xmlns 'publish', NS_PUBSUB
  18
+
  19
+      ##
  20
+      # support for enumerating <item> elements
  21
+      def each(&block)
  22
+        items.each(&block)
  23
+      end
  24
+
  25
+      ##
  26
+      # return child <item> elements
  27
+      def items
  28
+        get_elements("item")
  29
+      end
  30
+
17 31
       ##
18 32
       # return the node for this publication
19 33
       def node

0 notes on commit 86f9209

Please sign in to comment.
Something went wrong with that request. Please try again.