Class: Prosody::PublishedDeque
- Inherits:
-
Object
- Object
- Prosody::PublishedDeque
- Includes:
- State::Scanning
- Defined in:
- lib/prosody/state.rb,
sig/state.rbs
Instance Method Summary collapse
- #each(key) {|arg0| ... } ⇒ Object
- #empty?(key) ⇒ Boolean
- #first(key) ⇒ T?
- #get(key, index) ⇒ T?
-
#initialize(native) ⇒ PublishedDeque
constructor
A new instance of PublishedDeque.
- #last(key) ⇒ T?
- #length(key) ⇒ Integer (also: #size)
- #reverse_each(key) {|arg0| ... } ⇒ Object
Methods included from State::Scanning
Constructor Details
#initialize(native) ⇒ PublishedDeque
Returns a new instance of PublishedDeque.
286 |
# File 'lib/prosody/state.rb', line 286 def initialize(native) = @native = native |
Instance Method Details
#each(key) ⇒ void #each(key) ⇒ Enumerator[T, void]
306 |
# File 'lib/prosody/state.rb', line 306 def each(key, &block) = traverse(key, :forward, &block) |
#empty?(key) ⇒ Boolean
302 |
# File 'lib/prosody/state.rb', line 302 def empty?(key) = @native.is_empty(key.to_s) |
#first(key) ⇒ T?
303 |
# File 'lib/prosody/state.rb', line 303 def first(key) = @native.peek_front(key.to_s) |
#get(key, index) ⇒ T?
288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/prosody/state.rb', line 288 def get(key, index) unless index.is_a?(Integer) raise TransientStateError, "get: index must be an Integer, got #{index.inspect}" end return @native.get(key.to_s, index) unless index.negative? return last(key) if index == -1 resolved = length(key) + index resolved.negative? ? nil : @native.get(key.to_s, resolved) end |
#last(key) ⇒ T?
304 |
# File 'lib/prosody/state.rb', line 304 def last(key) = @native.peek_back(key.to_s) |
#length(key) ⇒ Integer Also known as: size
300 |
# File 'lib/prosody/state.rb', line 300 def length(key) = @native.length(key.to_s) |
#reverse_each(key) ⇒ void #reverse_each(key) ⇒ Enumerator[T, void]
307 |
# File 'lib/prosody/state.rb', line 307 def reverse_each(key, &block) = traverse(key, :backward, &block) |