class Just

Public Class Methods

new(value) click to toggle source
# File lib/matilda-maybe/just.rb, line 11
def initialize(value)
  @value = value
end

Public Instance Methods

==(object) click to toggle source
# File lib/matilda-maybe/just.rb, line 33
def ==(object)
  if object.class == Just
    object.value == self.value
  else
    false
  end
end
bind(&block) click to toggle source
# File lib/matilda-maybe/just.rb, line 15
def bind(&block)
  computed = block.call(@value)
  warn("Not returning a Maybe from #bind is really bad form...") unless computed.kind_of?(Maybe)
  computed
end
get(*args, &block) click to toggle source
# File lib/matilda-maybe/just.rb, line 29
def get(*args, &block)
  @value
end
map(&block) click to toggle source
# File lib/matilda-maybe/just.rb, line 21
def map(&block)
  Just.new(block.call(@value))
end
method_missing(method_name, *args, &block) click to toggle source
# File lib/matilda-maybe/just.rb, line 2
def method_missing(method_name, *args, &block)
  values = args.map { |arg|
    return Nothing.new if arg == Nothing.new
    arg.kind_of?(Just) ? arg.value : arg
  }

  Just.new(@value.public_send(method_name, *values, &block))
end
or(*args, &block) click to toggle source
# File lib/matilda-maybe/just.rb, line 25
def or(*args, &block)
  self
end

Protected Instance Methods

value() click to toggle source
# File lib/matilda-maybe/just.rb, line 43
def value
  @value
end