Class: LibXMLJRuby::XML::Node::Set

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/libxml-jruby/xml/node.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSet

Returns a new instance of Set.



254
255
256
257
# File 'lib/libxml-jruby/xml/node.rb', line 254

def initialize
  @java_obj = java_obj
  @node_cache = {}
end

Instance Attribute Details

#java_objObject

Returns the value of attribute java_obj.



252
253
254
# File 'lib/libxml-jruby/xml/node.rb', line 252

def java_obj
  @java_obj
end

Class Method Details

.from_java(java_obj) ⇒ Object



243
244
245
246
247
# File 'lib/libxml-jruby/xml/node.rb', line 243

def from_java(java_obj)
  s = new
  s.java_obj = java_obj
  s
end

Instance Method Details

#[](index) ⇒ Object



267
268
269
# File 'lib/libxml-jruby/xml/node.rb', line 267

def [](index)
  @node_cache[index] ||= LibXMLJRuby::XML::Node.from_java(java_obj.item(index))
end

#eachObject



275
276
277
278
279
280
281
# File 'lib/libxml-jruby/xml/node.rb', line 275

def each
  i = 0
  while(i < java_obj.length)
    yield self[i]
    i += 1
  end
end

#empty?Boolean

Returns:

  • (Boolean)


263
264
265
# File 'lib/libxml-jruby/xml/node.rb', line 263

def empty?
  java_obj.length < 1
end

#firstObject



271
272
273
# File 'lib/libxml-jruby/xml/node.rb', line 271

def first
  self[0]
end

#lengthObject



259
260
261
# File 'lib/libxml-jruby/xml/node.rb', line 259

def length
  java_obj.length
end