lib/option.rb in option-0.0.1 vs lib/option.rb in option-0.0.2
- old
+ new
@@ -1,16 +1,16 @@
-class Option
+class OptionClass
def or_nil
end
def ==(that)
or_nil == that.or_nil
end
end
-class Some < Option
+class SomeClass < OptionClass
def initialize(value)
@value = value
end
@@ -45,11 +45,11 @@
end
def flat_map(&blk)
result = blk.call(get)
case result
- when Option then return result
+ when OptionClass then return result
else raise TypeError, "Must be Option"
end
end
def fold(if_empty, &blk)
@@ -59,11 +59,11 @@
def exists?(&blk)
!! blk.call(get)
end
end
-class NoneClass < Option
+class NoneClass < OptionClass
def to_a
[]
end
@@ -105,10 +105,10 @@
end
None = NoneClass.new
def Some(value)
- Some.new(value)
+ SomeClass.new(value)
end
def Option(value)
value.nil? ? None : Some(value)
end