Class: Mores::LinkedList::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/mores/linked_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(list, value) ⇒ Node

Returns a new instance of Node.



128
129
130
131
# File 'lib/mores/linked_list.rb', line 128

def initialize(list, value)
  @list = list
  @value = value
end

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



125
126
127
# File 'lib/mores/linked_list.rb', line 125

def list
  @list
end

#nextObject

Returns the value of attribute next.



125
126
127
# File 'lib/mores/linked_list.rb', line 125

def next
  @next
end

#prevObject

Returns the value of attribute prev.



125
126
127
# File 'lib/mores/linked_list.rb', line 125

def prev
  @prev
end

#valueObject

Returns the value of attribute value.



126
127
128
# File 'lib/mores/linked_list.rb', line 126

def value
  @value
end

Instance Method Details

#<(value) ⇒ Object



133
134
135
136
# File 'lib/mores/linked_list.rb', line 133

def <(value)
  list.send :insert, @prev, self, value
  self
end

#>(value) ⇒ Object



138
139
140
141
# File 'lib/mores/linked_list.rb', line 138

def >(value)
  list.send :insert, self, @next, value
  self
end

#deleteObject



143
144
145
146
147
# File 'lib/mores/linked_list.rb', line 143

def delete
  list.send :remove, self
  clear
  value
end