Class: Rangeable::Slot
- Inherits:
-
Struct
- Object
- Struct
- Rangeable::Slot
- Defined in:
- lib/rangeable/slot.rb
Overview
Thin wrapper returned by ‘Rangeable#[]`. Wraps the active-element list at a single coordinate so we can grow the surface (e.g. add `count`, `transitions`, etc.) without changing the public type.
‘objs` is always a frozen `Array` of elements ordered by first-insert `ord(e)` ascending (RFC §4.5). We use a `Struct` (rather than a plain class) because the hot-path call sites are `r.objs` and the Struct accessor is materially faster than going through `attr_reader` + an ivar in MRI.
Instance Attribute Summary collapse
-
#objs ⇒ Object
Returns the value of attribute objs.
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #inspect ⇒ Object
- #size ⇒ Object (also: #count, #length)
- #to_a ⇒ Object
Instance Attribute Details
#objs ⇒ Object
Returns the value of attribute objs
13 14 15 |
# File 'lib/rangeable/slot.rb', line 13 def objs @objs end |
Instance Method Details
#each(&block) ⇒ Object
24 25 26 |
# File 'lib/rangeable/slot.rb', line 24 def each(&block) objs.each(&block) end |
#empty? ⇒ Boolean
14 15 16 |
# File 'lib/rangeable/slot.rb', line 14 def empty? objs.empty? end |
#inspect ⇒ Object
32 33 34 |
# File 'lib/rangeable/slot.rb', line 32 def inspect "#<Rangeable::Slot objs=#{objs.inspect}>" end |
#size ⇒ Object Also known as: count, length
18 19 20 |
# File 'lib/rangeable/slot.rb', line 18 def size objs.size end |
#to_a ⇒ Object
28 29 30 |
# File 'lib/rangeable/slot.rb', line 28 def to_a objs.dup end |