Class: Rexle::Elements
Instance Method Summary collapse
- #[](raw_i) ⇒ Object
- #each(&blk) ⇒ Object
- #empty? ⇒ Boolean
- #index(e = nil, &blk) ⇒ Object
-
#initialize(elements = []) ⇒ Elements
constructor
A new instance of Elements.
- #last ⇒ Object
- #length ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(elements = []) ⇒ Elements
Returns a new instance of Elements.
1374 1375 1376 1377 |
# File 'lib/rexle.rb', line 1374 def initialize(elements=[]) super() @elements = elements end |
Instance Method Details
#[](raw_i) ⇒ Object
1379 1380 1381 1382 1383 1384 |
# File 'lib/rexle.rb', line 1379 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
1386 |
# File 'lib/rexle.rb', line 1386 def each(&blk) @elements.each(&blk) end |
#empty? ⇒ Boolean
1387 |
# File 'lib/rexle.rb', line 1387 def empty?() @elements.empty? end |
#index(e = nil, &blk) ⇒ Object
1389 1390 1391 1392 1393 1394 1395 1396 |
# File 'lib/rexle.rb', line 1389 def index(e=nil, &blk) if block_given? then @elements.index(&blk) else @elements.index e end end |
#last ⇒ Object
1398 |
# File 'lib/rexle.rb', line 1398 def last() @elements.last end |
#length ⇒ Object
1399 |
# File 'lib/rexle.rb', line 1399 def length() @elements.length end |
#to_a ⇒ Object
1400 |
# File 'lib/rexle.rb', line 1400 def to_a() @elements end |