infinity 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,38 @@
1
1
  = infinity
2
2
 
3
- Description goes here.
3
+ Class to deal with Infinity conditions.
4
+ Regular arithmatic:
5
+
6
+ 3 * Infinity # => Infinity
7
+ 3 + Infinity # => Infinity
8
+ 3 / Infinity # => Infinity
9
+ 3 - Infinity # => Infinity
10
+
11
+ Infinity arithmatic:
12
+
13
+ 0 * Infinity #=> 0
14
+ Infinity * Infinity # => Infinity
15
+ Infinity + Infinity # => Infinity
16
+ Infinity / Infinity # => 1
17
+ Infinity - Infinity # => 0
18
+
19
+ Infinity comparisons
20
+
21
+ Infinity > 23 # => true
22
+ Infinity < 23 # => false
23
+ Infinity < Object # => false
24
+ Infinity > Object # => true
25
+ Infinity == Infinity # => true
26
+ Infinity > Infinity # => false
27
+ Infinity < Infinity # => false
28
+
29
+
30
+ to handle division by zero without raising an error.
31
+
32
+ require 'infinity/zero'
33
+
34
+ 3 / 0 # => Infinity
35
+ 3.0 / 0 # => Infinity
4
36
 
5
37
  == Note on Patches/Pull Requests
6
38
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.8
@@ -0,0 +1,53 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{infinity}
8
+ s.version = "0.0.8"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Daniel Bretoi"]
12
+ s.date = %q{2010-07-10}
13
+ s.description = %q{simple lib to deal with infinate numbers}
14
+ s.email = %q{daniel@netwalk.org}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ "LICENSE",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "infinity.gemspec",
25
+ "lib/infinity.rb",
26
+ "lib/infinity/zero.rb",
27
+ "test/helper.rb",
28
+ "test/test_infinity.rb"
29
+ ]
30
+ s.homepage = %q{http://github.com/danielb2/infinity}
31
+ s.rdoc_options = ["--charset=UTF-8"]
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = %q{1.3.7}
34
+ s.summary = %q{simple lib to deal with infinate numbers}
35
+ s.test_files = [
36
+ "test/helper.rb",
37
+ "test/test_infinity.rb"
38
+ ]
39
+
40
+ if s.respond_to? :specification_version then
41
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
42
+ s.specification_version = 3
43
+
44
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
46
+ else
47
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
48
+ end
49
+ else
50
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
51
+ end
52
+ end
53
+
@@ -4,6 +4,8 @@ class Infinity
4
4
  self
5
5
  end
6
6
  def -(obj)
7
+ return 0 if obj == Infinity
8
+ return 0 if obj.kind_of? Infinity
7
9
  self
8
10
  end
9
11
  def /(obj)
@@ -17,9 +19,13 @@ class Infinity
17
19
  self
18
20
  end
19
21
  def >(obj)
22
+ return false if obj == Infinity
23
+ return false if obj.kind_of? Infinity
20
24
  true
21
25
  end
22
26
  def <(obj)
27
+ return false if obj == Infinity
28
+ return false if obj.kind_of? Infinity
23
29
  false
24
30
  end
25
31
  def to_str
@@ -7,6 +7,9 @@ class TestInfinity < Test::Unit::TestCase
7
7
  assert_equal(Infinity, (Infinity / 23))
8
8
  assert_equal(Infinity, (Infinity * 23))
9
9
  assert_equal(1, (Infinity / Infinity))
10
+ assert_equal(0, (Infinity - Infinity))
11
+ assert_equal(Infinity, (Infinity * Infinity))
12
+ assert_equal(Infinity, (Infinity + Infinity))
10
13
  assert_equal(1, (Infinity.new / Infinity))
11
14
  assert_equal(1, (Infinity.new / Infinity.new))
12
15
  assert_equal(0, Infinity * 0)
@@ -17,6 +20,10 @@ class TestInfinity < Test::Unit::TestCase
17
20
  assert(Infinity > 23)
18
21
  assert_equal(false, Infinity < 23)
19
22
  assert(Infinity == Infinity)
23
+ assert_equal(false, Infinity < Infinity)
24
+ assert_equal(false, Infinity > Infinity)
25
+ assert_equal(true, Infinity > Time)
26
+ assert_equal(false, Infinity < Time)
20
27
  end
21
28
 
22
29
  should "test string" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infinity
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 7
10
- version: 0.0.7
9
+ - 8
10
+ version: 0.0.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Bretoi
@@ -46,6 +46,7 @@ files:
46
46
  - README.rdoc
47
47
  - Rakefile
48
48
  - VERSION
49
+ - infinity.gemspec
49
50
  - lib/infinity.rb
50
51
  - lib/infinity/zero.rb
51
52
  - test/helper.rb