Class: Slcsp::Index
- Inherits:
-
Object
- Object
- Slcsp::Index
- Defined in:
- lib/slcsp/index.rb
Overview
Sort of inverted index, in fact a simple hash for fast finds zip -> [rate_area, rate_area] e.g. => [‘VA 11’, ‘VA 12’], ‘75025’ => [‘TX 1’, ‘TX 2’]
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #get(key) ⇒ Object
-
#initialize(data = {}) ⇒ Index
constructor
A new instance of Index.
- #set(key, val) ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ Index
Returns a new instance of Index.
7 8 9 |
# File 'lib/slcsp/index.rb', line 7 def initialize(data={}) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
11 12 13 |
# File 'lib/slcsp/index.rb', line 11 def data @data end |
Instance Method Details
#get(key) ⇒ Object
13 14 15 |
# File 'lib/slcsp/index.rb', line 13 def get(key) @data.key?(key) ? @data[key] : nil end |
#set(key, val) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/slcsp/index.rb', line 17 def set(key, val) if @data.key?(key) @data[key] << val else @data[key] = [val] end end |