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.
- #length ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(elements = []) ⇒ Elements
Returns a new instance of Elements.
1343 1344 1345 1346 |
# File 'lib/rexle.rb', line 1343 def initialize(elements=[]) super() @elements = elements end |
Instance Method Details
#[](raw_i) ⇒ Object
1348 1349 1350 1351 1352 1353 |
# File 'lib/rexle.rb', line 1348 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
1355 |
# File 'lib/rexle.rb', line 1355 def each(&blk) @elements.each(&blk) end |
#empty? ⇒ Boolean
1356 |
# File 'lib/rexle.rb', line 1356 def empty?() @elements.empty? end |
#index(e = nil, &blk) ⇒ Object
1358 1359 1360 1361 1362 1363 1364 1365 |
# File 'lib/rexle.rb', line 1358 def index(e=nil, &blk) if block_given? then @elements.index(&blk) else @elements.index e end end |
#length ⇒ Object
1367 |
# File 'lib/rexle.rb', line 1367 def length() @elements.length end |
#to_a ⇒ Object
1368 |
# File 'lib/rexle.rb', line 1368 def to_a() @elements end |