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

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

#__filter__, #__flatmap__, #__flatmap_with_each__, #__inject_while__, #__lazy_take__, #__lazy_take_until__, #__lazy_take_while__, #__map__, #__scan__, #__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

Instance Method Details

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

Raises:

  • (ArgumentError)


22
23
24
25
26
# File 'lib/lab42/stream/empty.rb', line 22

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:

  • (Boolean)


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

def empty?; true end

#headObject

Raises:

  • (StopIteration)


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

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

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



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

def inject *args; args.first end

#itself(*args, &blk) ⇒ Object

TODO: Move this into lab42/core as Object#itself



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

def itself *args, &blk; self end

#scan(initial, *args, &blk) ⇒ Object



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

def scan initial, *args, &blk
  [initial]
end

#scan1(*args, &blk) ⇒ Object



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

def scan1 *args, &blk
  []
end

#tailObject

Raises:

  • (StopIteration)


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

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