Class: Rupture::LazySeq

Inherits:
Seq show all
Defined in:
lib/rupture/lazy_seq.rb

Constant Summary

Constants inherited from Seq

Seq::Empty

Instance Method Summary collapse

Methods inherited from Seq

#[], #eql?, #inspect, #to_ary

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

Constructor Details

#initialize(block = nil) ⇒ LazySeq

Returns a new instance of LazySeq.



5
6
7
# File 'lib/rupture/lazy_seq.rb', line 5

def initialize(block = nil)
  @block = block
end

Instance Method Details

#seqObject



9
10
11
12
13
14
# File 'lib/rupture/lazy_seq.rb', line 9

def seq
  return @seq unless @block
  @seq   = @block.call.seq
  @block = nil
  @seq
end