Class: RDF::Microdata::Reader::Nokogiri::NodeSetProxy

Inherits:
Object
  • Object
show all
Defined in:
vendor/bundler/ruby/2.4.0/bundler/gems/rdf-microdata-14cc40c62067/lib/rdf/microdata/reader/nokogiri.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



125
126
127
128
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-microdata-14cc40c62067/lib/rdf/microdata/reader/nokogiri.rb', line 125

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



171
172
173
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-microdata-14cc40c62067/lib/rdf/microdata/reader/nokogiri.rb', line 171

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

Instance Attribute Details

#node_setObject (readonly)

Returns the value of attribute node_set



122
123
124
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-microdata-14cc40c62067/lib/rdf/microdata/reader/nokogiri.rb', line 122

def node_set
  @node_set
end

#parentObject (readonly)

Returns the value of attribute parent



123
124
125
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-microdata-14cc40c62067/lib/rdf/microdata/reader/nokogiri.rb', line 123

def parent
  @parent
end

Instance Method Details

#+(other) ⇒ NodeSetProxy

Add NodeSetProxys

Parameters:

Returns:



152
153
154
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-microdata-14cc40c62067/lib/rdf/microdata/reader/nokogiri.rb', line 152

def +(other)
  NodeSetProxy.new(self.node_set + other.node_set, parent)
end

#<<(elem) ⇒ NodeSetProxy

Add a NodeProxy

Parameters:

Returns:



160
161
162
163
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-microdata-14cc40c62067/lib/rdf/microdata/reader/nokogiri.rb', line 160

def <<(elem)
  node_set << (elem.is_a?(NodeProxy) ? elem.node : elem)
  self
end

#each {|child| ... } ⇒ Object

Return a proxy for each child

Yields:

  • child

Yield Parameters:



135
136
137
138
139
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-microdata-14cc40c62067/lib/rdf/microdata/reader/nokogiri.rb', line 135

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

#inspectObject



165
166
167
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-microdata-14cc40c62067/lib/rdf/microdata/reader/nokogiri.rb', line 165

def inspect
  @node_set.map {|c| NodeProxy.new(c, parent).display_path}.inspect
end

#shiftNodeProxy

Return proxy for first element and remove it

Returns:



144
145
146
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-microdata-14cc40c62067/lib/rdf/microdata/reader/nokogiri.rb', line 144

def shift
  (e = node_set.shift) && NodeProxy.new(e, parent)
end