Class: Bx
- Inherits:
-
Object
- Object
- Bx
- Defined in:
- lib/bx.rb,
lib/bx/version.rb
Constant Summary collapse
- VERSION =
"0.1.1"
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, id) ⇒ Object
- #bits_bytes ⇒ Object
-
#initialize ⇒ Bx
constructor
A new instance of Bx.
- #keys ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize ⇒ Bx
Returns a new instance of Bx.
34 35 36 |
# File 'lib/bx.rb', line 34 def initialize @hash = Hash.new{ |h, k| h[k] = 0 } end |
Instance Method Details
#[](key) ⇒ Object
42 43 44 |
# File 'lib/bx.rb', line 42 def [](key) @hash[key] end |
#[]=(key, id) ⇒ Object
38 39 40 |
# File 'lib/bx.rb', line 38 def []=(key, id) @hash[key] |= (1 << id) end |
#bits_bytes ⇒ Object
54 55 56 |
# File 'lib/bx.rb', line 54 def bits_bytes @hash.each_value.sum(&:size) end |
#keys ⇒ Object
46 47 48 |
# File 'lib/bx.rb', line 46 def keys @hash.keys end |
#values ⇒ Object
50 51 52 |
# File 'lib/bx.rb', line 50 def values @hash.values end |