stish 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/stish.rb +20 -0
  3. metadata +45 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1d734062dc4b4279c836853cffa22faa6323496c
4
+ data.tar.gz: df4c23fe7e083a2665cdedcc2d4cb7472a9598d9
5
+ SHA512:
6
+ metadata.gz: 9600acecbd1327bbc76ba62f4aa17068be0125ae4acde8ad25b09fedf3e54faa3564ae76b83f273e0c1b46e169830844c5a7b7156212e14857b518e59ebeac29
7
+ data.tar.gz: d25039eb32f1b5a0ce47196ac7bad76d8c37d394719e3186cc06600569ee61215a3d0b02960953cceac8cbb3a84b7ab72e1638ac782db57cd8e3a0b4de107818
@@ -0,0 +1,20 @@
1
+ class Object
2
+ def if_not_nil(arg = nil, &block)
3
+ return yield(self) if block_given?
4
+ return arg
5
+ end
6
+
7
+ def if_nil(arg = nil, &block)
8
+ return self
9
+ end
10
+ end
11
+ class NilClass
12
+ def if_not_nil(arg = nil, &block)
13
+ return self
14
+ end
15
+
16
+ def if_nil(arg = nil, &block)
17
+ return yield if block_given?
18
+ return arg
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stish
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tom Leuse
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-01-31 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: 'Very small gem that adds if_nil(&block) and if_not_nil(&block) methods
14
+ (mimicking Smalltalk''s ifNil: and ifNotNil:) to ruby.'
15
+ email: tom.leuse@kuleuven.be
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/stish.rb
21
+ homepage: https://github.com/tomleuse/stish
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.5.2
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: 'Add ST ifNil: and ifNotNil: to ruby'
45
+ test_files: []