Class: Dbxml::XmlDocument::MetaData

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

Overview

Represents the document metadata as an Enumerable collection

Instance Method Summary collapse

Constructor Details

#initialize(doc) ⇒ MetaData

:nodoc:



130
131
132
# File 'lib/rdbxml.rb', line 130

def initialize(doc)  #:nodoc:
  @doc = doc
end

Instance Method Details

#[](name, ns = '') ⇒ Object



134
135
136
137
# File 'lib/rdbxml.rb', line 134

def [](name, ns = '')
  v = XmlValue.new
  @doc.( ns, name.to_s, v ) ? v : nil
end

#[]=(name, *args) ⇒ Object



139
140
141
142
143
144
145
146
147
148
# File 'lib/rdbxml.rb', line 139

def []=(name, *args)
  opts = {}
  val = args.pop
  ns = args.shift || ''
  if val
    @doc. ns, name.to_s, Dbxml::XmlValue.new(val)
  else
    delete name, ns
  end
end

#delete(name, ns = '') ⇒ Object



150
151
152
153
# File 'lib/rdbxml.rb', line 150

def delete(name, ns = '')
#puts "removeMetaData: #{name.inspect}, #{ns.inspect}"
  @doc. ns, name.to_s
end

#each(&block) ⇒ Object

:yields: name, value, uri



155
156
157
158
159
160
# File 'lib/rdbxml.rb', line 155

def each(&block) # :yields: name, value, uri
  i = @doc.getMetaDataIterator
  while (xmd = i.next)
    yield xmd.get_name.to_sym, xmd.get_value, xmd.get_uri
  end
end

#inspectObject



169
170
171
172
173
# File 'lib/rdbxml.rb', line 169

def inspect
  all = {}
  self.each { |n, v|  all[n] = v }
  all.inspect
end

#sizeObject



162
163
164
165
166
167
# File 'lib/rdbxml.rb', line 162

def size
  s = 0
  i = @doc.getMetaDataIterator
  while i.next  do  s += 1  end
  s
end