Class: RRList::Stores::InMemoryArray
- Inherits:
-
Object
- Object
- RRList::Stores::InMemoryArray
- Defined in:
- lib/rrlist/stores.rb
Overview
An implementation of a store that follows the contract
Instance Method Summary collapse
- #fill(value, range) ⇒ Object
- #fill_with_nils ⇒ Object
- #get(index) ⇒ Object
-
#initialize ⇒ InMemoryArray
constructor
A new instance of InMemoryArray.
- #put(index, value) ⇒ Object
- #raw ⇒ Object
- #set_values(values) ⇒ Object
- #start_at(position) ⇒ Object
Constructor Details
#initialize ⇒ InMemoryArray
Returns a new instance of InMemoryArray.
8 9 10 |
# File 'lib/rrlist/stores.rb', line 8 def initialize @values = [] end |
Instance Method Details
#fill(value, range) ⇒ Object
30 31 32 33 |
# File 'lib/rrlist/stores.rb', line 30 def fill(value, range) @values.fill(value,range) nil end |
#fill_with_nils ⇒ Object
25 26 27 28 |
# File 'lib/rrlist/stores.rb', line 25 def fill_with_nils @values.fill(nil) nil end |
#get(index) ⇒ Object
21 22 23 |
# File 'lib/rrlist/stores.rb', line 21 def get(index) @values[index] end |
#put(index, value) ⇒ Object
16 17 18 19 |
# File 'lib/rrlist/stores.rb', line 16 def put(index,value) @values[index] = value nil end |
#raw ⇒ Object
35 36 37 |
# File 'lib/rrlist/stores.rb', line 35 def raw @values end |
#set_values(values) ⇒ Object
12 13 14 |
# File 'lib/rrlist/stores.rb', line 12 def set_values(values) @values = values end |
#start_at(position) ⇒ Object
39 40 41 |
# File 'lib/rrlist/stores.rb', line 39 def start_at(position) @values[position..@values.size] + @values[0...position] end |