Class: Dbxml::XmlResults

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rdbxml.rb

Overview

Wraps the XmlResults class as an enumerable collection of XmlValue or XmlDocument.

Instance Method Summary collapse

Instance Method Details

#each(&block) ⇒ Object

Iterates across each result (as an XmlValue) in the set



70
71
72
73
74
75
# File 'lib/rdbxml.rb', line 70

def each( &block ) # :yields: value
  self.reset
  while self.hasNext
    yield self.next
  end
end

#each_doc(&block) ⇒ Object

Iterates across each result (as an XmlDocument) in the set



78
79
80
81
82
83
# File 'lib/rdbxml.rb', line 78

def each_doc( &block ) # :yields: document
  self.reset
  while self.hasNext
    yield self.nextDocument
  end
end

#firstObject

Returns the first result as an XmlValue(or nil)



86
87
88
89
# File 'lib/rdbxml.rb', line 86

def first
  self.reset
  self.hasNext ? self.next : nil
end

#first_docObject

Returns the first result as an XmlDocument (or nil)



92
93
94
95
# File 'lib/rdbxml.rb', line 92

def first_doc
  self.reset
  self.hasNext ? self.nextDocument : nil
end

#to_sObject

Returns the result set as newline-joined strings



98
99
100
# File 'lib/rdbxml.rb', line 98

def to_s
  collect { |v| v.to_s }.join "\n"
end