class Blank

The class represents a lack of something.

Public Instance Methods

==(other) click to toggle source

Is this wrapped value equal to the given wrapped value? All blank values are equal to each other.

> nil.wrapped == nil.wrapped > 1.wrapped == nil.wrapped

# File lib/wrapped/blank.rb, line 96
def ==(other)
  other.is_a?(Blank)
end
blank(&block) click to toggle source

Call the block then return itself. This is chainable. See present for its companion.

w.blank { puts “I got nothing” }.present {|n| puts “got #{n}” }

# File lib/wrapped/blank.rb, line 33
def blank(&block)
  block.call
  self
end
blank?() click to toggle source

True; this is an instance of nothing.

# File lib/wrapped/blank.rb, line 70
def blank?
  true
end
collect()
Alias for: fmap
each() click to toggle source

Produce the empty list.

This class mixes in the Enumerable module, which relies on this.

> w.each {|n| puts n }

# File lib/wrapped/blank.rb, line 43
def each
  self
end
find_all()
Alias for: select
flat_map() click to toggle source

Do nothing, returning itself.

> w.flat_map {|n| n+1 }

# File lib/wrapped/blank.rb, line 77
def flat_map
  self
end
fmap() click to toggle source

Do nothing, returning itself.

> w.fmap {|n| n+1 }

# File lib/wrapped/blank.rb, line 84
def fmap
  self
end
Also aliased as: collect, map
grep(*) click to toggle source

Produces itself.

# File lib/wrapped/blank.rb, line 60
def grep(*)
  self
end
map()
Alias for: fmap
present() click to toggle source

Does nothing, returning itself. This is chainable. See blank for its companion.

w.present.blank { puts “Missing” }

# File lib/wrapped/blank.rb, line 25
def present
  self
end
present?() click to toggle source

False; this is not an instance of a wrapped value.

# File lib/wrapped/blank.rb, line 65
def present?
  false
end
reject() click to toggle source

Produces itself.

# File lib/wrapped/blank.rb, line 55
def reject
  self
end
select() click to toggle source

Produces itself.

# File lib/wrapped/blank.rb, line 48
def select
  self
end
Also aliased as: find_all
unwrap() click to toggle source

It is an error (specifically, an IndexError) to use this method.

# File lib/wrapped/blank.rb, line 6
def unwrap
  raise IndexError.new("Blank has no value")
end
unwrap_or(default = nil) { || ... } click to toggle source

Produce the value that is passed in.

> w.unwrap_or(0)

# File lib/wrapped/blank.rb, line 13
def unwrap_or(default = nil)
  if block_given?
    yield
  else
    default
  end
end