Class: Rupture::Seq

Inherits:
Object show all
Includes:
Enumerable, Sequence
Defined in:
lib/rupture/seq.rb

Direct Known Subclasses

ArraySeq, Cons, LazySeq, List, EmptySeq

Defined Under Namespace

Classes: EmptySeq

Constant Summary collapse

Empty =
EmptySeq.new

Instance Method Summary collapse

Methods included from Sequence

#concat, #conj, #count, #divide, #doall, #drop, #drop_last, #drop_while, #each, #empty?, #every?, #filter, #first, #flatten, #foldr, #frequencies, #into, #last, #map, #map_indexed, #mapcat, #next, #not_empty, #nth, #partition, #partition_all, #partition_between, #partition_by, #reduce, #reductions, #remove, #rest, #reverse, #second, #separate, #sequential?, #some, #sort, #sort_by, #split_at, #split_with, #take, #take_last, #take_while, #tree_seq

Methods included from Enumerable

#seq

Instance Method Details

#[](index) ⇒ Object



10
11
12
# File 'lib/rupture/seq.rb', line 10

def [](index)
  nth(index)
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rupture/seq.rb', line 18

def eql?(other)
  return false unless other.respond_to?(:seq)

  s = self.seq
  o = other.seq
  while s && o
    return false if s.first != o.first
    s = s.next
    o = o.next
  end

  s.nil? and o.nil?
end

#inspectObject



6
7
8
# File 'lib/rupture/seq.rb', line 6

def inspect
  "(#{to_a.collect(&:inspect).join(',')})"
end

#to_aryObject



14
15
16
# File 'lib/rupture/seq.rb', line 14

def to_ary
  to_a
end