Class: RRList::Stores::InMemoryArray

Inherits:
Object
  • Object
show all
Defined in:
lib/rrlist/stores.rb

Overview

An implementation of a store that follows the contract

Author:

  • Federico Dayan

Instance Method Summary collapse

Constructor Details

#initializeInMemoryArray

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_nilsObject



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

#rawObject



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