Class: Rexle::Elements

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

Instance Method Summary collapse

Constructor Details

#initialize(elements = []) ⇒ Elements

Returns a new instance of Elements.



1369
1370
1371
1372
# File 'lib/rexle.rb', line 1369

def initialize(elements=[])
  super()
  @elements = elements
end

Instance Method Details

#[](raw_i) ⇒ Object



1374
1375
1376
1377
1378
1379
# File 'lib/rexle.rb', line 1374

def [](raw_i)

  raise 'Rexle::Elements index (-1) must be >= 1' unless raw_i > 0
  i = raw_i - 1
  @elements[i]
end

#each(&blk) ⇒ Object



1381
# File 'lib/rexle.rb', line 1381

def each(&blk) @elements.each(&blk)  end

#empty?Boolean

Returns:

  • (Boolean)


1382
# File 'lib/rexle.rb', line 1382

def empty?()   @elements.empty?      end

#index(e = nil, &blk) ⇒ Object



1384
1385
1386
1387
1388
1389
1390
1391
# File 'lib/rexle.rb', line 1384

def index(e=nil, &blk)
  
  if block_given? then
    @elements.index(&blk)
  else
    @elements.index e
  end
end

#lastObject



1393
# File 'lib/rexle.rb', line 1393

def last()     @elements.last        end

#lengthObject



1394
# File 'lib/rexle.rb', line 1394

def length()   @elements.length      end

#to_aObject



1395
# File 'lib/rexle.rb', line 1395

def to_a()     @elements             end