null_and_void 1.1.4 → 1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,12 +6,20 @@ module NullAndVoid
6
6
  0
7
7
  end
8
8
 
9
+ def to_c
10
+ Complex(0)
11
+ end
12
+
9
13
  alias :to_int :to_i
10
14
 
11
15
  def to_f
12
16
  0.0
13
17
  end
14
18
 
19
+ def rationalize(*args)
20
+ Rational(0)
21
+ end
22
+
15
23
  def to_r
16
24
  Rational(0)
17
25
  end
@@ -3,5 +3,9 @@ module NullAndVoid
3
3
  def null_object?
4
4
  true
5
5
  end
6
+
7
+ def inspect
8
+ "#<#{self.class.name}:0x#{(__id__ * 2).to_s(16)}>"
9
+ end
6
10
  end
7
11
  end
@@ -1,3 +1,3 @@
1
1
  module NullAndVoid
2
- VERSION = '1.1.4'
2
+ VERSION = '1.2'
3
3
  end
@@ -25,6 +25,11 @@ describe NullAndVoid::Convertible do
25
25
  null_object.to_int.should be_zero
26
26
  end
27
27
 
28
+ it 'is zero when the attempt is made to convert it to a Complex number' do
29
+ null_object.to_c.should be_a Complex
30
+ null_object.to_c.should be_zero
31
+ end
32
+
28
33
  it 'is zero when the attempt is made to convert it to a Float' do
29
34
  null_object.to_f.should be_a Float
30
35
  null_object.to_f.should be_zero
@@ -33,6 +38,9 @@ describe NullAndVoid::Convertible do
33
38
  it 'is zero when the attempt is made to convert it to a Rational' do
34
39
  null_object.to_r.should be_a Rational
35
40
  null_object.to_r.should be_zero
41
+
42
+ null_object.rationalize.should be_a Rational
43
+ null_object.rationalize.should be_zero
36
44
  end
37
45
 
38
46
  it 'is an empty Array when the attempt is made to convert it to an Array' do
@@ -1,14 +1,18 @@
1
1
  require 'rspectacular'
2
2
  require 'null_and_void/introspectable'
3
3
 
4
- class MyNullOjbect
4
+ class MyNullObject
5
5
  include NullAndVoid::Introspectable
6
6
  end
7
7
 
8
8
  describe NullAndVoid::Introspectable do
9
- let(:null_object) { MyNullOjbect.new }
9
+ let(:null_object) { MyNullObject.new }
10
10
 
11
11
  it 'knows it is a null object' do
12
12
  null_object.should be_null_object
13
13
  end
14
+
15
+ it 'can inspect itself' do
16
+ null_object.inspect.should match /\A#<MyNullObject:0x[a-f0-9]{12}>\z/
17
+ end
14
18
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: null_and_void
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.1.4
5
+ version: '1.2'
6
6
  platform: ruby
7
7
  authors:
8
8
  - jfelchner
@@ -52,13 +52,13 @@ dependencies:
52
52
  requirements:
53
53
  - - ~>
54
54
  - !ruby/object:Gem::Version
55
- version: '0.7'
55
+ version: '0.11'
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '0.7'
61
+ version: '0.11'
62
62
  description: Makes generating Null Objects easy.
63
63
  email: accounts+git@thekompanee.com
64
64
  executables: []