Class: Lab42::Stream::Empty

Inherits:
Lab42::Stream show all
Extended by:
Forwarder
Defined in:
lib/lab42/stream/empty.rb

Constant Summary

Constants inherited from Lab42::Stream

ConstraintError, EmptyStream, IllegalState, Version

Instance Attribute Summary

Attributes inherited from Lab42::Stream

#promise

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Lab42::Stream

#__combine_streams__, #combine_streams, #drop, #to_stream

Methods included from ClassMethods

#iterate

Methods included from HigherOrder

#__combine__, #combine, #split_into

Methods included from Enumerable

#__drop_while__, #__filter__, #__flatmap__, #__flatmap_with_each__, #__inject_while__, #__lazy_take__, #__lazy_take_until__, #__lazy_take_while__, #__map__, #__scan__, #__take_while__, #__zip__, #drop_until, #drop_while, #each, #each_without_loops, #filter, #flatmap, #flatmap_with_each, #force_all, #lazy_take, #lazy_take_until, #lazy_take_while, #make_cyclic, #map, #reduce, #reduce_while, #reject, #take, #take_until, #take_while, #to_a, #zip, #zip_as_ary

Methods included from Utility

#__segment__, #segment, #with_index

Class Method Details

.newObject



47
48
49
# File 'lib/lab42/stream/empty.rb', line 47

def self.new
  @__instance__ ||= allocate
end

Instance Method Details

#append(other) ⇒ Object Also known as: +

Raises:



19
20
21
22
23
# File 'lib/lab42/stream/empty.rb', line 19

def append other
  raise ArgumentError, "not a stream #{other}" unless self.class.superclass === other
  # ??? Is the to_stream message a good idea
  other.to_stream
end

#empty?Boolean

Returns:



26
# File 'lib/lab42/stream/empty.rb', line 26

def empty?; true end

#headObject

Raises:



29
# File 'lib/lab42/stream/empty.rb', line 29

def head; raise StopIteration, "head called on empty stream" end

#inject(*args) ⇒ Object Also known as: __inject__



33
# File 'lib/lab42/stream/empty.rb', line 33

def inject *args; args.first end

#itselfObject



36
# File 'lib/lab42/stream/empty.rb', line 36

def itself *; self end

#scan(initial) ⇒ Object



38
39
40
# File 'lib/lab42/stream/empty.rb', line 38

def scan( initial, * )
  [initial]
end

#scan1Object



42
43
44
# File 'lib/lab42/stream/empty.rb', line 42

def scan1( * )
  []
end

#tailObject

Raises:



30
# File 'lib/lab42/stream/empty.rb', line 30

def tail; raise StopIteration, "tail called on empty stream" end