Class: RDF::RDFXML::Reader::REXML::NodeSetProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/rdf/rdfxml/reader/rexml.rb

Overview

NodeSet proxy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node_set, parent) ⇒ NodeSetProxy

Returns a new instance of NodeSetProxy.



208
209
210
211
# File 'lib/rdf/rdfxml/reader/rexml.rb', line 208

def initialize(node_set, parent)
  @node_set = node_set
  @parent = parent
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object

Proxy for everything else to @node_set



238
239
240
# File 'lib/rdf/rdfxml/reader/rexml.rb', line 238

def method_missing(method, *args)
  @node_set.send(method, *args)
end

Instance Attribute Details

#node_setObject (readonly)

Returns the value of attribute node_set.



205
206
207
# File 'lib/rdf/rdfxml/reader/rexml.rb', line 205

def node_set
  @node_set
end

#parentObject (readonly)

Returns the value of attribute parent.



206
207
208
# File 'lib/rdf/rdfxml/reader/rexml.rb', line 206

def parent
  @parent
end

Instance Method Details

#each {|| ... } ⇒ Object

Return a proxy for each child

Yields:

  • child

Yield Parameters:



218
219
220
221
222
# File 'lib/rdf/rdfxml/reader/rexml.rb', line 218

def each
  @node_set.to_a.each do |c|
    yield NodeProxy.new(c, parent)
  end
end

#select {|| ... } ⇒ Array[NodeProxy]

Return selected NodeProxies based on selection

Yields:

  • child

Yield Parameters:

Returns:



230
231
232
233
234
# File 'lib/rdf/rdfxml/reader/rexml.rb', line 230

def select
  @node_set.to_a.map {|n| NodeProxy.new(n, parent)}.select do |c|
    yield c
  end
end