Class: Cache::LinkedList::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/background_queue/server_lib/lru.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value, next_element) ⇒ Element

Returns a new instance of Element.



172
173
174
175
176
177
# File 'lib/background_queue/server_lib/lru.rb', line 172

def initialize(key, value, next_element)
  @key = key
  @value = value
  @next_element = next_element
  @previous_element = nil
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



171
172
173
# File 'lib/background_queue/server_lib/lru.rb', line 171

def key
  @key
end

#next_elementObject

Returns the value of attribute next_element.



171
172
173
# File 'lib/background_queue/server_lib/lru.rb', line 171

def next_element
  @next_element
end

#previous_elementObject

Returns the value of attribute previous_element.



171
172
173
# File 'lib/background_queue/server_lib/lru.rb', line 171

def previous_element
  @previous_element
end

#valueObject

Returns the value of attribute value.



171
172
173
# File 'lib/background_queue/server_lib/lru.rb', line 171

def value
  @value
end

Instance Method Details

#inspectObject



179
180
181
# File 'lib/background_queue/server_lib/lru.rb', line 179

def inspect
  to_s
end

#to_sObject



183
184
185
186
187
# File 'lib/background_queue/server_lib/lru.rb', line 183

def to_s
  p = @previous_element ? @previous_element.key : 'nil'
  n = @next_element ? @next_element.key : 'nil'
  "[#{@key}: #{@value.inspect}, previous: #{p}, next: #{n}]"
end