Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

documentation update

  • Loading branch information...
commit 1b6fa6df77f7456e152e3278e0724661a720d9dc 1 parent 5e06805
@ms-ati authored
Showing with 12 additions and 8 deletions.
  1. +4 −4 lib/rumonade/either.rb
  2. +8 −4 lib/rumonade/option.rb
View
8 lib/rumonade/either.rb
@@ -94,12 +94,12 @@ class Either
# Projects an Either into a Left.
class LeftProjection
class << self
- # Returns a +LeftProjection+ of the +Left+ of the given value
+ # @return [LeftProjection] Returns a +LeftProjection+ of the +Left+ of the given value
def unit(value)
self.new(Left(value))
end
- # Returns the empty +LeftProjection+ (over a +Right+)
+ # @return [LeftProjection] Returns the empty +LeftProjection+
def empty
self.new(Right(nil))
end
@@ -144,12 +144,12 @@ def all?(lam = nil, &blk)
# Projects an Either into a Right.
class RightProjection
class << self
- # Returns a +RightProjection+ of the +Right+ of the given value
+ # @return [RightProjection] Returns a +RightProjection+ of the +Right+ of the given value
def unit(value)
self.new(Right(value))
end
- # Returns the empty +RightProjection+ (over a +Left+)
+ # @return [RightProjection] Returns the empty +RightProjection+
def empty
self.new(Left(nil))
end
View
12 lib/rumonade/option.rb
@@ -35,22 +35,24 @@ module Rumonade # :nodoc:
# puts "No name value"
# end
#
+ # @abstract
class Option
class << self
- # Returns a new Option containing the given value
+ # @return [Option] Returns an +Option+ containing the given value
def unit(value)
Rumonade.Option(value)
end
- # Returns the empty Option (None)
+ # @return [Option] Returns the empty +Option+
def empty
None
end
end
- def initialize # :nodoc:
+ def initialize
raise(TypeError, "class Option is abstract; cannot be instantiated") if self.class == Option
end
+ private :initialize
# Returns None if None, or the result of executing the given block or lambda on the contents if Some
def bind(lam = nil, &blk)
@@ -59,7 +61,7 @@ def bind(lam = nil, &blk)
include Monad
- # Returns +true+ if None, +false+ if Some
+ # @return [Boolean] Returns +true+ if +None+, +false+ if +Some+
def empty?
raise(NotImplementedError)
end
@@ -89,6 +91,7 @@ def initialize(value)
attr_reader :value # :nodoc:
+ # @return (see Option#empty?)
def empty?
false
end
@@ -106,6 +109,7 @@ def to_s
class NoneClass < Option
include Singleton
+ # @return (see Option#empty?)
def empty?
true
end
Please sign in to comment.
Something went wrong with that request. Please try again.