Class: Hyperactive::List::Element
- Inherits:
-
Record::Bass
- Object
- Record::Bass
- Hyperactive::List::Element
- Includes:
- Archipelago::Current::ThreadedCollection
- Defined in:
- lib/hyperactive/list.rb
Overview
A wrapper class that knows its previous and next List::Elements as well as its value and the id of its list.
Instance Attribute Summary collapse
-
#list_id ⇒ Object
Returns the value of attribute list_id.
-
#next ⇒ Object
Returns the value of attribute next.
-
#previous ⇒ Object
Returns the value of attribute previous.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#each(&block) ⇒ Object
Yield to
block
once for this and each following element. -
#initialize(previous_element, next_element, value, list_id) ⇒ Element
constructor
Initialize this List::Element with given
previous_element
,next_element
,value
andlist_id
.
Methods included from Transactions::Accessors
Methods included from Index::Indexable
Methods included from Record::Persistent
#<=>, append_features, #create, #destroy!, #with_transaction
Constructor Details
#initialize(previous_element, next_element, value, list_id) ⇒ Element
Initialize this List::Element with given previous_element
, next_element
, value
and list_id
.
40 41 42 43 44 45 |
# File 'lib/hyperactive/list.rb', line 40 def initialize(previous_element, next_element, value, list_id) self.previous = previous_element self.next = next_element self.value = value self.list_id = list_id end |
Instance Attribute Details
#list_id ⇒ Object
Returns the value of attribute list_id.
35 36 37 |
# File 'lib/hyperactive/list.rb', line 35 def list_id @list_id end |
#next ⇒ Object
Returns the value of attribute next.
35 36 37 |
# File 'lib/hyperactive/list.rb', line 35 def next @next end |
#previous ⇒ Object
Returns the value of attribute previous.
35 36 37 |
# File 'lib/hyperactive/list.rb', line 35 def previous @previous end |
#value ⇒ Object
Returns the value of attribute value.
35 36 37 |
# File 'lib/hyperactive/list.rb', line 35 def value @value end |
Instance Method Details
#each(&block) ⇒ Object
Yield to block
once for this and each following element.
49 50 51 52 53 54 55 |
# File 'lib/hyperactive/list.rb', line 49 def each(&block) element = self while element yield(element) element = self.next end end |