fu_nil 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +15 -0
- data/lib/fu_nil.rb +29 -0
- metadata +49 -0
data/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# FU NIL
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
From recent frustrations a co-worker had with nil and division of zero in Ruby comes the fu-nil gem. Not pronounced foo but rather Eff You as a giant middle finger to the Ruby nil and not being allowed to be used in math operators. The division by zero is an added luxury to the fu-nil gem.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
gem install fu_nil
|
10
|
+
irb
|
11
|
+
require 'rubygems'
|
12
|
+
require 'fu_nil'
|
13
|
+
5 + nil + 3 # 8
|
14
|
+
100.0 / 0 # 0
|
15
|
+
100 / nil # 0
|
data/lib/fu_nil.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module FuNil
|
2
|
+
|
3
|
+
end
|
4
|
+
|
5
|
+
class NilClass
|
6
|
+
|
7
|
+
def method_missing(meth, *args, &block)
|
8
|
+
0.send(meth, *args)
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
class Fixnum
|
14
|
+
|
15
|
+
def /(x)
|
16
|
+
return 0 if x.zero?
|
17
|
+
super x
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
class Float
|
23
|
+
|
24
|
+
def /(x)
|
25
|
+
return 0 if x.zero?
|
26
|
+
super x
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fu_nil
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chavez
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-22 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Allows the ruby nil to be used in math operators. Allows the amazing
|
15
|
+
division of zero.
|
16
|
+
email: ''
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files:
|
20
|
+
- README.md
|
21
|
+
files:
|
22
|
+
- lib/fu_nil.rb
|
23
|
+
- README.md
|
24
|
+
homepage: http://github.com/mtchavez/fu-nil
|
25
|
+
licenses: []
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options:
|
28
|
+
- --charset=UTF-8 --main=README.md
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements: []
|
44
|
+
rubyforge_project:
|
45
|
+
rubygems_version: 1.8.17
|
46
|
+
signing_key:
|
47
|
+
specification_version: 3
|
48
|
+
summary: FU NIL
|
49
|
+
test_files: []
|