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.



1408
1409
1410
1411
# File 'lib/rexle.rb', line 1408

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

Instance Method Details

#[](raw_i) ⇒ Object



1413
1414
1415
1416
1417
1418
# File 'lib/rexle.rb', line 1413

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



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

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

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?()   @elements.empty?      end

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



1423
1424
1425
1426
1427
1428
1429
1430
# File 'lib/rexle.rb', line 1423

def index(e=nil, &blk)

  if block_given? then
    @elements.index(&blk)
  else
    @elements.index e
  end
end

#lastObject



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

def last()     @elements.last        end

#lengthObject



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

def length()   @elements.length      end

#to_aObject



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

def to_a()     @elements             end