Class: Matching::ArrayStore
- Inherits:
-
Object
- Object
- Matching::ArrayStore
- Defined in:
- lib/matching/array_store.rb
Overview
Stores and retrieves data from arrays for Matcher
Instance Attribute Summary collapse
-
#arr ⇒ Object
readonly
Returns the value of attribute arr.
Instance Method Summary collapse
-
#each(&blk) ⇒ Object
Iterates over array, also returning index as a kind of ID.
-
#find(idx) ⇒ Object
Return an object from the array by its index position.
-
#initialize(arr) ⇒ ArrayStore
constructor
A new instance of ArrayStore.
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
#arr ⇒ Object (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 |