monad-oxide 0.6.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/lib/err.rb +10 -0
  3. data/lib/ok.rb +11 -0
  4. data/lib/result.rb +11 -0
  5. data/lib/version.rb +1 -1
  6. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9152af4e006e8a978a78be5124827b09d97ec352f5415cbf32d28db8eef6918a
4
- data.tar.gz: e197a94f8b60ba971f112eb9ea49f82773acfc378ab5595dc1536575cdc27dd7
3
+ metadata.gz: 7c37567d8988443ab1076e07e5784fa454f430a12400acbb15526de2164a2686
4
+ data.tar.gz: a09be57539e071b3094b1d052cff724f0b71e8ae22ecd3ed151ffc355984b041
5
5
  SHA512:
6
- metadata.gz: 7cb457a2987b557e1a32cc9b7dd0587a825c2bcdcd6c4f99e04774a3b858cf0f19a8775163287a6db0500833fe804a2bdd5b6dc26293267b75eabf763597ecad
7
- data.tar.gz: 612b7b37f4e4a2cead728bd7465909d88375c72c1b169cd2e1880b4a173fd585831ed88acaad2fd88becaeda03aebcffa6171f924cfba6b00e94da1307a78e92
6
+ metadata.gz: a0b562a479e20ec1f488fe476c60c1c7138aa62f67b9cb83ca526ce0ff4e97a8c193d75062a175a466e877ae27b163ab9162cf72352126122035aa397024ac88
7
+ data.tar.gz: a78393ad99ebe353b9a9ccdbc31756e87a9578e768fa4b47fbef1bd756b08baa131b52ff69129a502d503e40daa44df283b678ec0ac26f5738b3bce562f003c9
data/lib/err.rb CHANGED
@@ -166,5 +166,15 @@ module MonadOxide
166
166
  @data
167
167
  end
168
168
 
169
+ ##
170
+ # Safely unwrap the `Result`. In the case of `Err`, this returns the
171
+ # provided default value.
172
+ #
173
+ # @param [T] x The value that will be returned.
174
+ # @return [T] The `x` value.
175
+ def unwrap_or(x)
176
+ x
177
+ end
178
+
169
179
  end
170
180
  end
data/lib/ok.rb CHANGED
@@ -123,5 +123,16 @@ module MonadOxide
123
123
  "#{self.class} with #{@data.inspect} could not be unwrapped as an Err.",
124
124
  )
125
125
  end
126
+
127
+ ##
128
+ # Safely unwrap the `Result`. In the case of `Ok`, this returns the
129
+ # data in the Ok.
130
+ #
131
+ # @param [B] x The value that will be returned.
132
+ # @return [A] The data in the Ok.
133
+ def unwrap_or(_)
134
+ @data
135
+ end
136
+
126
137
  end
127
138
  end
data/lib/result.rb CHANGED
@@ -225,5 +225,16 @@ module MonadOxide
225
225
  def unwrap_err()
226
226
  Err.new(ResultMethodNotImplementedError.new())
227
227
  end
228
+
229
+ ##
230
+ # Attempt to safely access the `Result` data. This always returns a value
231
+ # instead of raising an Exception. In the case of `Ok`, the data is
232
+ # returned. In the case of `Err`, the value provided is returned.
233
+ # @param _ [B] The value to use for `Err`.
234
+ # @return [T|B] The inner data of this `Ok` or the passee value.
235
+ def unwrap_or(_)
236
+ Err.new(ResultMethodNotImplementedError.new())
237
+ end
238
+
228
239
  end
229
240
  end
data/lib/version.rb CHANGED
@@ -3,5 +3,5 @@ module MonadOxide
3
3
  # This version is locked to 0.x.0 because semver is a lie and this project
4
4
  # uses CICD to push new versions. Any commits that appear on main will result
5
5
  # in a new version of the gem created and published.
6
- VERSION='0.6.0'
6
+ VERSION='0.8.0'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monad-oxide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Logan Barnett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-22 00:00:00.000000000 Z
11
+ date: 2023-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: org-ruby