Class: Xenum::MergeSort::Candidate

Inherits:
Object
  • Object
show all
Defined in:
lib/xenum/merge_sort.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#valueObject

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

#fetchObject



114
115
116
117
118
# File 'lib/xenum/merge_sort.rb', line 114

def fetch
  @value = @enum.next
rescue StopIteration
  @value = NULL
end