Class: Xenum::MergeSort::Candidate
- Inherits:
-
Object
- Object
- Xenum::MergeSort::Candidate
- Defined in:
- lib/xenum/merge_sort.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #<=>(another) ⇒ Object
- #fetch ⇒ Object
-
#initialize(enum) ⇒ Candidate
constructor
A new instance of Candidate.
Constructor Details
#initialize(enum) ⇒ Candidate
Returns a new instance of Candidate.
105 106 107 108 |
# File 'lib/xenum/merge_sort.rb', line 105 def initialize(enum) @enum = Enumerator === enum ? enum : enum.to_enum fetch end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
103 104 105 |
# File 'lib/xenum/merge_sort.rb', line 103 def value @value end |
Instance Method Details
#<=>(another) ⇒ Object
110 111 112 |
# File 'lib/xenum/merge_sort.rb', line 110 def <=>(another) value <=> another.value end |
#fetch ⇒ Object
114 115 116 117 118 |
# File 'lib/xenum/merge_sort.rb', line 114 def fetch @value = @enum.next rescue StopIteration @value = NULL end |