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.
1396 1397 1398 1399 |
# File 'lib/rexle.rb', line 1396 def initialize(elements=[]) super() @elements = elements end |
Instance Method Details
#[](raw_i) ⇒ Object
1401 1402 1403 1404 1405 1406 |
# File 'lib/rexle.rb', line 1401 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
1408 |
# File 'lib/rexle.rb', line 1408 def each(&blk) @elements.each(&blk) end |
#empty? ⇒ Boolean
1409 |
# File 'lib/rexle.rb', line 1409 def empty?() @elements.empty? end |
#index(e = nil, &blk) ⇒ Object
1411 1412 1413 1414 1415 1416 1417 1418 |
# File 'lib/rexle.rb', line 1411 def index(e=nil, &blk) if block_given? then @elements.index(&blk) else @elements.index e end end |
#last ⇒ Object
1420 |
# File 'lib/rexle.rb', line 1420 def last() @elements.last end |
#length ⇒ Object
1421 |
# File 'lib/rexle.rb', line 1421 def length() @elements.length end |
#to_a ⇒ Object
1422 |
# File 'lib/rexle.rb', line 1422 def to_a() @elements end |