Class: Ohm::Set
- Inherits:
-
Collection
- Object
- Collection
- Ohm::Set
- Defined in:
- lib/ohm/collection.rb
Overview
Represents a Redis set.
Instance Method Summary (collapse)
- - (Object) <<(value)
- - (Object) all
- - (Object) delete(value)
- - (Boolean) include?(value)
- - (Object) inspect
-
- (Integer) size
Returns the number of elements in the set.
Methods inherited from Collection
#==, #[], #clear, #concat, #each, #empty?, #first, #initialize, #replace, #sort, #to_ary
Constructor Details
This class inherits a constructor from Ohm::Collection
Instance Method Details
- (Object) <<(value)
161 162 163 |
# File 'lib/ohm/collection.rb', line 161 def << value db.sadd(key, value) end |
- (Object) all
173 174 175 |
# File 'lib/ohm/collection.rb', line 173 def all db.smembers(key) end |
- (Object) delete(value)
165 166 167 |
# File 'lib/ohm/collection.rb', line 165 def delete(value) db.srem(key, value) end |
- (Boolean) include?(value)
169 170 171 |
# File 'lib/ohm/collection.rb', line 169 def include?(value) db.sismember(key, value) end |
- (Object) inspect
182 183 184 |
# File 'lib/ohm/collection.rb', line 182 def inspect "#<Set: #{all.inspect}>" end |
- (Integer) size
Returns the number of elements in the set.
178 179 180 |
# File 'lib/ohm/collection.rb', line 178 def size db.scard(key) end |