simple_monads 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e7e3ebe8e7b05581ce43b1b3cc4b7a0228f8cf23bba47e63170105925efd016
4
- data.tar.gz: 3fc317d3276dec52162e31b0b506a12d9ffd5745b1a9520a8b67a01340e1810e
3
+ metadata.gz: 55714bdd3d9033064a313fdcbe6652e95d47a2825c840e4caefe98ed31a00cc3
4
+ data.tar.gz: 7e47070fa7811435c6035db49b2cc2842fd06db63ffc67fd24846552b4ff3fda
5
5
  SHA512:
6
- metadata.gz: 7b95b48a2fc1a975e4972bf3a45f020647652c73d7dd0d2d7aa7a0fa5e2d962cfc0e6ddc062d17954029dd226c45cd664ac0c7e1cffd4e2cd77034abd7ea1f87
7
- data.tar.gz: f835c9d1d43b7fa2a01266eaf31d3f190ed3298dd99544862a9af4fc4e2c058106f32a6fccbadad313aa01df0512a5ede1ab71fd054ee4a51aef1321f7ddf8ce
6
+ metadata.gz: 52b545aba9f0146ac012c3b5ad80faacdc62606c53ebf605fbc8ae57f0344c2f4dc5758cbabeaa8f14d9aa583756c8dc9ef970afa792d31cfbe8fa142f4a487c
7
+ data.tar.gz: 886c5859ca487ca083d5a190affb1cf792dafa204d78e1f2260d0a95547dbaa604af3c14e37efc55e5150efccc5a915c4057bc4b98bea229095a1c3f1578cecf
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleMonads
4
+ # failure object
5
+ class FailureObject
6
+ attr_reader :object
7
+ alias failure object
8
+
9
+ def initialize(object)
10
+ @object = object
11
+ end
12
+
13
+ def failure?
14
+ true
15
+ end
16
+
17
+ def success?
18
+ false
19
+ end
20
+
21
+ def inspect
22
+ "Failure(#{object})"
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleMonads
4
+ # success object
5
+ class SuccessObject
6
+ attr_reader :object
7
+ alias success object
8
+
9
+ def initialize(object)
10
+ @object = object
11
+ end
12
+
13
+ def failure?
14
+ false
15
+ end
16
+
17
+ def success?
18
+ true
19
+ end
20
+
21
+ def inspect
22
+ "Success(#{object})"
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SimpleMonads
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.3'
5
5
  end
data/lib/simple_monads.rb CHANGED
@@ -1,4 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'simple_monads/failure_object'
4
+ require_relative 'simple_monads/success_object'
5
+
6
+ # Main module
3
7
  module SimpleMonads
8
+ def Success(object) # rubocop:disable Naming/MethodName
9
+ SuccessObject.new(object)
10
+ end
11
+
12
+ def Failure(object) # rubocop:disable Naming/MethodName
13
+ FailureObject.new(object)
14
+ end
4
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_monads
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Leonov
@@ -17,6 +17,8 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - lib/simple_monads.rb
20
+ - lib/simple_monads/failure_object.rb
21
+ - lib/simple_monads/success_object.rb
20
22
  - lib/simple_monads/version.rb
21
23
  homepage: https://github.com/leonovk/simple_monads
22
24
  licenses: