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.
1348 1349 1350 1351 |
# File 'lib/rexle.rb', line 1348 def initialize(elements=[]) super() @elements = elements end |
Instance Method Details
#[](raw_i) ⇒ Object
1353 1354 1355 1356 1357 1358 |
# File 'lib/rexle.rb', line 1353 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
1360 |
# File 'lib/rexle.rb', line 1360 def each(&blk) @elements.each(&blk) end |
#empty? ⇒ Boolean
1361 |
# File 'lib/rexle.rb', line 1361 def empty?() @elements.empty? end |
#index(e = nil, &blk) ⇒ Object
1363 1364 1365 1366 1367 1368 1369 1370 |
# File 'lib/rexle.rb', line 1363 def index(e=nil, &blk) if block_given? then @elements.index(&blk) else @elements.index e end end |
#last ⇒ Object
1372 |
# File 'lib/rexle.rb', line 1372 def last() @elements.last end |
#length ⇒ Object
1373 |
# File 'lib/rexle.rb', line 1373 def length() @elements.length end |
#to_a ⇒ Object
1374 |
# File 'lib/rexle.rb', line 1374 def to_a() @elements end |