Class: HashTable::StringHashTraits
- Inherits:
-
StringIdentityHashTraits
- Object
- IdentityHashTraits
- StringIdentityHashTraits
- HashTable::StringHashTraits
- Defined in:
- lib/hashtable/traits.rb
Overview
StringHashTraits
Instance Attribute Summary collapse
-
#buckets ⇒ Object
readonly
Returns the value of attribute buckets.
-
#string_table ⇒ Object
readonly
Returns the value of attribute string_table.
Instance Method Summary collapse
-
#initialize(&block) ⇒ StringHashTraits
constructor
A new instance of StringHashTraits.
- #lookup_key_to_storage_value(key, values) ⇒ Object
Methods inherited from StringIdentityHashTraits
#hash_lookup_key, #lookup_key_to_storage_key, #storage_key_to_lookup_key
Constructor Details
#initialize(&block) ⇒ StringHashTraits
Returns a new instance of StringHashTraits.
51 52 53 54 |
# File 'lib/hashtable/traits.rb', line 51 def initialize(&block) super @block = block end |
Instance Attribute Details
#buckets ⇒ Object (readonly)
Returns the value of attribute buckets.
49 50 51 |
# File 'lib/hashtable/traits.rb', line 49 def buckets @buckets end |
#string_table ⇒ Object (readonly)
Returns the value of attribute string_table.
49 50 51 |
# File 'lib/hashtable/traits.rb', line 49 def string_table @string_table end |
Instance Method Details
#lookup_key_to_storage_value(key, values) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/hashtable/traits.rb', line 56 def lookup_key_to_storage_value(key, values) return if values.nil? || values.empty? bs = values.map { |v| lookup_key_to_storage_key(v) }.unshift(key) return bs if @block.nil? @block.call(bs) end |