Class: Bx

Inherits:
Object
  • Object
show all
Defined in:
lib/bx.rb,
lib/bx/version.rb

Constant Summary collapse

VERSION =
"0.1.1"

Instance Method Summary collapse

Constructor Details

#initializeBx

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_bytesObject



54
55
56
# File 'lib/bx.rb', line 54

def bits_bytes
  @hash.each_value.sum(&:size)
end

#keysObject



46
47
48
# File 'lib/bx.rb', line 46

def keys
  @hash.keys
end

#valuesObject



50
51
52
# File 'lib/bx.rb', line 50

def values
  @hash.values
end