Class: Klam::Absvector
- Inherits:
-
Array
- Object
- Array
- Klam::Absvector
- Defined in:
- lib/klam/absvector.rb
Instance Method Summary collapse
- #[](i) ⇒ Object
- #[]=(i, x) ⇒ Object
-
#each(&blk) ⇒ Object
In Shen, the data types that are implemented on top of absvectors use index 0 for auxilliary information.
- #store(i, x) ⇒ Object
- #to_a ⇒ Object
Instance Method Details
#[](i) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/klam/absvector.rb', line 3 def [](i) if i < 0 || i >= size raise Klam::Error, "index out of bounds: #{i}" end super(i) end |
#[]=(i, x) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/klam/absvector.rb', line 10 def []=(i, x) if i < 0 || i >= size raise Klam::Error, "index out of bounds: #{i}" end super(i, x) end |
#each(&blk) ⇒ Object
In Shen, the data types that are implemented on top of absvectors use index 0 for auxilliary information. To ease interop scenarios, to_a and each are overridden to skip the first slot.
25 26 27 |
# File 'lib/klam/absvector.rb', line 25 def each(&blk) to_a.each(&blk) end |
#store(i, x) ⇒ Object
17 18 19 20 |
# File 'lib/klam/absvector.rb', line 17 def store(i, x) self[i] = x self end |
#to_a ⇒ Object
29 30 31 32 33 |
# File 'lib/klam/absvector.rb', line 29 def to_a a = super a.shift a end |