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.



1235
1236
1237
1238
# File 'lib/rexle.rb', line 1235

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

Instance Method Details

#[](raw_i) ⇒ Object



1240
1241
1242
1243
1244
1245
# File 'lib/rexle.rb', line 1240

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



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

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

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?()   @elements.empty?      end

#lengthObject



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

def length()   @elements.length      end

#to_aObject



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

def to_a()     @elements             end