Class: RDF::Microdata::Reader::Nokogiri::NodeSetProxy
- Inherits:
-
Object
- Object
- RDF::Microdata::Reader::Nokogiri::NodeSetProxy
- Defined in:
- lib/rdf/microdata/reader/nokogiri.rb
Overview
NodeSet proxy
Instance Attribute Summary collapse
-
#node_set ⇒ Object
readonly
Returns the value of attribute node_set.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
-
#+(other) ⇒ NodeSetProxy
Add NodeSetProxys.
-
#<<(elem) ⇒ NodeSetProxy
Add a NodeProxy.
-
#each {|child| ... } ⇒ Object
Return a proxy for each child.
-
#initialize(node_set, parent) ⇒ NodeSetProxy
constructor
A new instance of NodeSetProxy.
- #inspect ⇒ Object
-
#method_missing(method, *args) ⇒ Object
Proxy for everything else to @node_set.
-
#shift ⇒ NodeProxy
Return proxy for first element and remove it.
Constructor Details
#initialize(node_set, parent) ⇒ NodeSetProxy
Returns a new instance of NodeSetProxy.
125 126 127 128 |
# File '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 'lib/rdf/microdata/reader/nokogiri.rb', line 171 def method_missing(method, *args) @node_set.send(method, *args) end |
Instance Attribute Details
#node_set ⇒ Object (readonly)
Returns the value of attribute node_set.
122 123 124 |
# File 'lib/rdf/microdata/reader/nokogiri.rb', line 122 def node_set @node_set end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
123 124 125 |
# File 'lib/rdf/microdata/reader/nokogiri.rb', line 123 def parent @parent end |
Instance Method Details
#+(other) ⇒ NodeSetProxy
Add NodeSetProxys
152 153 154 |
# File '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
160 161 162 163 |
# File '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
135 136 137 138 139 |
# File 'lib/rdf/microdata/reader/nokogiri.rb', line 135 def each @node_set.each do |c| yield NodeProxy.new(c, parent) end end |
#inspect ⇒ Object
165 166 167 |
# File 'lib/rdf/microdata/reader/nokogiri.rb', line 165 def inspect @node_set.map {|c| NodeProxy.new(c, parent).display_path}.inspect end |