maybe_not 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/maybe/nothing.rb +33 -0
- data/lib/maybe/something.rb +33 -0
- data/lib/maybe_not.rb +6 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b5cb40c690cd8ef3afa0e2e41016b11c9a7aa3d1
|
4
|
+
data.tar.gz: f6207cad5add51a3e18094e154f8f06903cf7339
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b7ffda1079991cc1ae2e5c67462bce99bcf305d4e0450565335baa172d00e33e0f9ed6b60772eb4f2ab7e5bfd6547723bb20851c6300202468a22c36d2345dd0
|
7
|
+
data.tar.gz: 2460e7422ed8e48e28e0a9072de0a3f68c5a3a97b375cdcc84a5b78c5d267627d127da1c17c31cd385b49472b0da0cc46ce12cc764cd8656fa8e72880ccf48ff
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module Maybe
|
4
|
+
class Nothing
|
5
|
+
include Singleton
|
6
|
+
|
7
|
+
class NothingToSeeHere < StandardError
|
8
|
+
def message
|
9
|
+
"called 'get' on Nothing"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def else(&blk)
|
14
|
+
blk.()
|
15
|
+
end
|
16
|
+
|
17
|
+
def get
|
18
|
+
raise NothingToSeeHere
|
19
|
+
end
|
20
|
+
|
21
|
+
def nothing?
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def something?
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
def method_missing(*)
|
30
|
+
self
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Maybe
|
2
|
+
class Something
|
3
|
+
def initialize(value)
|
4
|
+
@value = value
|
5
|
+
end
|
6
|
+
|
7
|
+
def get
|
8
|
+
value
|
9
|
+
end
|
10
|
+
|
11
|
+
alias_method :else, :get
|
12
|
+
|
13
|
+
def if_something(&blk)
|
14
|
+
blk.(value)
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def nothing?
|
19
|
+
false
|
20
|
+
end
|
21
|
+
|
22
|
+
def something?
|
23
|
+
true
|
24
|
+
end
|
25
|
+
|
26
|
+
def method_missing(method, *args, &blk)
|
27
|
+
Maybe(value.send(method, *args, &blk))
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
attr_reader :value
|
32
|
+
end
|
33
|
+
end
|
data/lib/maybe_not.rb
ADDED
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: maybe_not
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Colson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-30 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Maybe a little Maybe monad
|
14
|
+
email: danieljamescolson@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/maybe/nothing.rb
|
20
|
+
- lib/maybe/something.rb
|
21
|
+
- lib/maybe_not.rb
|
22
|
+
homepage: https://github.com/composerinteralia/maybe_not
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.5.1
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: It's Something or Nothing
|
46
|
+
test_files: []
|