Starts a POP3
session and iterates over each POPMail
object, yielding it to the block
. This method is equivalent to:
Net::POP3.start(address, port, account, password) do |pop| pop.each_mail do |m| yield m end end
This method raises a POPAuthenticationError
if authentication fails.
Net::POP3.foreach('pop.example.com', 110, 'YourAccount', 'YourPassword') do |m| file.write m.pop m.delete if $DELETE end
Searches key
in id
list. The result is returned or yielded if a block is given. If it isn’t found, nil is returned.
Completion
for hash key.
Iterates the given block for each prime number.
Iterate over the key/value pairs:
attlist_decl.each { |attribute_name, attribute_value| ... }
Iterates through all of the child Elements
, optionally filtering them by a given XPath
optional. If supplied, this is a String
XPath
, and is used to filter the children, so that only matching children are yielded. Note that XPaths are automatically filtered for Elements
, so that non-Element children will not be yielded
doc = Document.new '<a><b/><c/><d/>sean<b/><c/><d/></a>' doc.root.elements.each {|e|p e} #-> Yields b, c, d, b, c, d elements doc.root.elements.each('b') {|e|p e} #-> Yields b, b elements doc.root.elements.each('child::node()') {|e|p e} #-> Yields <b/>, <c/>, <d/>, <b/>, <c/>, <d/> XPath.each(doc.root, 'child::node()', &block) #-> Yields <b/>, <c/>, <d/>, sean, <b/>, <c/>, <d/>
Iterates over each attribute of an Element
, yielding the expanded name and value as a pair of Strings.
doc = Document.new '<a x="1" y="2"/>' doc.root.attributes.each {|name, value| p name+" => "+value }
Evaluates whether the given string matches an entity definition, returning true if so, and false otherwise.
Enumerates rows of the Enumerable
objects.
check for illegal characters
Iterates over nodes that match the given path, calling the supplied block with the match.
The context element
The xpath to search for. If not supplied or nil, defaults to ‘*’
If supplied, a Hash
which defines a namespace mapping
If supplied, a Hash
which maps $variables in the query to values. This can be used to avoid XPath
injection attacks or to automatically handle escaping string values.
XPath.each( node ) { |el| ... } XPath.each( node, '/*[@attr='v']' ) { |el| ... } XPath.each( node, 'ancestor::x' ) { |el| ... } XPath.each( node, '/book/publisher/text()=$publisher', {}, {"publisher"=>"O'Reilly"}) \ {|el| ... }
Returns an array of nodes matching a given XPath
.
Fetches item k
from the tuple.
Iterate through the tuple, yielding the index or key, and the value, thus ensuring arrays are iterated similarly to hashes.
Matches this template against tuple
. The tuple
must be the same size as the template. An element with a nil
value in a template acts as a wildcard, matching any value in the corresponding position in the tuple. Elements of the template match the tuple
if the are ==
or ===
.
Template.new([:foo, 5]).match Tuple.new([:foo, 5]) # => true Template.new([:foo, nil]).match Tuple.new([:foo, 5]) # => true Template.new([String]).match Tuple.new(['hello']) # => true Template.new([:foo]).match Tuple.new([:foo, 5]) # => false Template.new([:foo, 6]).match Tuple.new([:foo, 5]) # => false Template.new([:foo, nil]).match Tuple.new([:foo]) # => false Template.new([:foo, 6]).match Tuple.new([:foo]) # => false
Iterates over all discovered TupleSpaces starting with the primary.