Class: XML::Feed::Builder::Rss::Items

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/xml/libxml/feed/builders/rss.rb

Instance Method Summary collapse

Constructor Details

#initialize(doc, channel) ⇒ Items

Returns a new instance of Items.



48
49
50
51
# File 'lib/xml/libxml/feed/builders/rss.rb', line 48

def initialize(doc, channel)
    @doc = doc
    @channel = channel
end

Instance Method Details

#[](x) ⇒ Object



65
66
67
# File 'lib/xml/libxml/feed/builders/rss.rb', line 65

def [](x)
    return Item.new(@channel, @channel.find('./item').to_a[x])
end

#create {|node| ... } ⇒ Object

Yields:

  • (node)


53
54
55
56
57
# File 'lib/xml/libxml/feed/builders/rss.rb', line 53

def create
    node = Item.new(@channel)
    yield node
    @channel << node.node
end

#eachObject



59
60
61
62
63
# File 'lib/xml/libxml/feed/builders/rss.rb', line 59

def each
    @channel.find('./item').each do |x|
        yield Item.new(@channel, x)
    end
end