just_maybe 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,6 +35,10 @@ class Maybe < BasicObject
35
35
  or_else { 0.0 }
36
36
  end
37
37
 
38
+ def or_false
39
+ or_else { false }
40
+ end
41
+
38
42
  def or_h
39
43
  or_else { {} }
40
44
  end
@@ -1,3 +1,3 @@
1
1
  module JustMaybe
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
data/spec/maybe_spec.rb CHANGED
@@ -24,7 +24,7 @@ describe Maybe do
24
24
  Maybe(object).__object__.should be(object)
25
25
  end
26
26
 
27
- it "#or_else returns then underlying object when it's not nil" do
27
+ it "#or_else returns the underlying object when it's not nil" do
28
28
  Maybe(object).or_else{'unexpected result'}.should == object
29
29
  end
30
30
 
@@ -32,7 +32,7 @@ describe Maybe do
32
32
  Maybe(nil).or_else{'expected result'}.should == 'expected result'
33
33
  end
34
34
 
35
- it "#or_a returns then underlying object when it's not nil" do
35
+ it "#or_a returns the underlying object when it's not nil" do
36
36
  Maybe(object).or_a.should be(object)
37
37
  end
38
38
 
@@ -40,7 +40,7 @@ describe Maybe do
40
40
  Maybe(nil).or_a.should == []
41
41
  end
42
42
 
43
- it "#or_f returns then underlying object when it's not nil" do
43
+ it "#or_f returns the underlying object when it's not nil" do
44
44
  Maybe(object).or_f.should be(object)
45
45
  end
46
46
 
@@ -48,7 +48,15 @@ describe Maybe do
48
48
  Maybe(nil).or_f.should == 0.0
49
49
  end
50
50
 
51
- it "#or_h returns then underlying object when it's not nil" do
51
+ it "#or_false returns the underlying object when it's not nil" do
52
+ Maybe(object).or_false.should be(object)
53
+ end
54
+
55
+ it "#or_false defaults to false" do
56
+ Maybe(nil).or_false.should be(false)
57
+ end
58
+
59
+ it "#or_h returns the underlying object when it's not nil" do
52
60
  Maybe(object).or_h.should be(object)
53
61
  end
54
62
 
@@ -56,7 +64,7 @@ describe Maybe do
56
64
  Maybe(nil).or_h.should == {}
57
65
  end
58
66
 
59
- it "#or_i returns then underlying object when it's not nil" do
67
+ it "#or_i returns the underlying object when it's not nil" do
60
68
  Maybe(object).or_i.should be(object)
61
69
  end
62
70
 
@@ -64,7 +72,7 @@ describe Maybe do
64
72
  Maybe(nil).or_i.should == 0
65
73
  end
66
74
 
67
- it "#or_nil returns then underlying object when it's not nil" do
75
+ it "#or_nil returns the underlying object when it's not nil" do
68
76
  Maybe(object).or_nil.should be(object)
69
77
  end
70
78
 
@@ -72,7 +80,7 @@ describe Maybe do
72
80
  Maybe(nil).or_nil.should == nil
73
81
  end
74
82
 
75
- it "#or_s returns then underlying object when it's not nil" do
83
+ it "#or_s returns the underlying object when it's not nil" do
76
84
  Maybe(object).or_s.should be(object)
77
85
  end
78
86
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: just_maybe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -48,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
48
  version: '0'
49
49
  requirements: []
50
50
  rubyforge_project:
51
- rubygems_version: 1.8.21
51
+ rubygems_version: 1.8.19
52
52
  signing_key:
53
53
  specification_version: 3
54
54
  summary: A simple implmenetation of the Maybe special case pattern