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.
Constant Summary
Constants inherited from Record::Bass
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.
Attributes inherited from Record::Bass
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 inherited from Record::Bass
#<=>, attr_accessor, attr_reader, attr_writer, #create, create_hooks, #destroy!, destroy_hooks, find, get_instance, get_instance_with_transaction, index_by, #load_hook, load_hooks, reject, #save_hook, save_hooks, select, setup, #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.
33 34 35 |
# File 'lib/hyperactive/list.rb', line 33 def list_id @list_id end |
#next ⇒ Object
Returns the value of attribute next.
33 34 35 |
# File 'lib/hyperactive/list.rb', line 33 def next @next end |
#previous ⇒ Object
Returns the value of attribute previous.
33 34 35 |
# File 'lib/hyperactive/list.rb', line 33 def previous @previous end |
#value ⇒ Object
Returns the value of attribute value.
33 34 35 |
# File 'lib/hyperactive/list.rb', line 33 def value @value end |
Instance Method Details
#each(&block) ⇒ Object
Yield to block
once for this and each following element.
50 51 52 53 54 55 56 |
# File 'lib/hyperactive/list.rb', line 50 def each(&block) element = self while element yield(element) element = self.next end end |