class Pair

Public Class Methods

new(first, second) click to toggle source
# File lib/totally_lazy/pair.rb, line 19
def initialize(first, second)
  @first = -> { first }
  @second = -> { second }
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/totally_lazy/pair.rb, line 40
def <=>(other)
  (first <=> other.first) <=> (second <=> other.second)
end
enumerator() click to toggle source
# File lib/totally_lazy/pair.rb, line 32
def enumerator
  Enumerator.new { |y|
    y << first
    y << second
    raise StopIteration.new
  }
end
first() click to toggle source
# File lib/totally_lazy/pair.rb, line 24
def first
  @first.()
end
second() click to toggle source
# File lib/totally_lazy/pair.rb, line 28
def second
  @second.()
end
to_s() click to toggle source
# File lib/totally_lazy/pair.rb, line 44
def to_s
  "(#{first}, #{second})"
end