Class: Async::Redis::Key
- Inherits:
-
Object
- Object
- Async::Redis::Key
- Includes:
- Comparable
- Defined in:
- lib/async/redis/key.rb
Overview
Represents a Redis key with utility methods for key manipulation.
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
-
.[](path) ⇒ Object
Create a new Key instance.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Compare this key with another key.
-
#[](key) ⇒ Object
Create a child key by appending a subkey.
-
#initialize(path) ⇒ Key
constructor
Initialize a new Key.
-
#size ⇒ Object
Get the byte size of the key.
-
#to_s ⇒ Object
Convert the key to a string.
-
#to_str ⇒ Object
Convert the key to a string (for String compatibility).
Constructor Details
#initialize(path) ⇒ Key
Initialize a new Key.
21 22 23 |
# File 'lib/async/redis/key.rb', line 21 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
31 32 33 |
# File 'lib/async/redis/key.rb', line 31 def path @path end |
Class Method Details
.[](path) ⇒ Object
Create a new Key instance.
13 14 15 |
# File 'lib/async/redis/key.rb', line 13 def self.[] path self.new(path) end |
Instance Method Details
#<=>(other) ⇒ Object
Compare this key with another key.
55 56 57 |
# File 'lib/async/redis/key.rb', line 55 def <=> other @path <=> other.to_str end |
#[](key) ⇒ Object
Create a child key by appending a subkey.
48 49 50 |
# File 'lib/async/redis/key.rb', line 48 def [] key self.class.new("#{@path}:#{key}") end |
#size ⇒ Object
Get the byte size of the key.
27 28 29 |
# File 'lib/async/redis/key.rb', line 27 def size @path.bytesize end |
#to_s ⇒ Object
Convert the key to a string.
35 36 37 |
# File 'lib/async/redis/key.rb', line 35 def to_s @path end |
#to_str ⇒ Object
Convert the key to a string (for String compatibility).
41 42 43 |
# File 'lib/async/redis/key.rb', line 41 def to_str @path end |