Class: Matching::ArrayStore

Inherits:
Object
  • Object
show all
Defined in:
lib/matching/array_store.rb

Overview

Stores and retrieves data from arrays for Matcher

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arr) ⇒ ArrayStore

Returns a new instance of ArrayStore.



8
9
10
# File 'lib/matching/array_store.rb', line 8

def initialize(arr)
  @arr = arr
end

Instance Attribute Details

#arrObject (readonly)

Returns the value of attribute arr.



6
7
8
# File 'lib/matching/array_store.rb', line 6

def arr
  @arr
end

Instance Method Details

#each(&blk) ⇒ Object

Iterates over array, also returning index as a kind of ID



13
14
15
# File 'lib/matching/array_store.rb', line 13

def each(&blk)
  @arr.each_with_index(&blk)
end

#find(idx) ⇒ Object

Return an object from the array by its index position



18
19
20
# File 'lib/matching/array_store.rb', line 18

def find(idx)
  @arr[idx]
end