Class: Rupture::LazySeq

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

Instance Method Summary collapse

Methods inherited from Seq

#==, #[], #each, empty, #to_ary

Methods included from Sequence

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

Constructor Details

#initialize(b = nil, &block) ⇒ LazySeq

Returns a new instance of LazySeq.



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

def initialize(b = nil, &block)
  @block = block || b
  super()
end

Instance Method Details

#seqObject



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

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