Skip to content

Commit

Permalink
Change Infinity class to use options for static class properties
Browse files Browse the repository at this point in the history
  • Loading branch information
dkubb committed Nov 11, 2013
1 parent 3b2e663 commit 7b30d5e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 36 deletions.
2 changes: 1 addition & 1 deletion config/flay.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
threshold: 19
total_score: 180
total_score: 175
2 changes: 1 addition & 1 deletion lib/axiom/types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def self.finalize
end # module Types
end # module Axiom

require 'axiom/types/support/infinity'
require 'axiom/types/support/options'
require 'axiom/types/support/infinity'

require 'axiom/types/value_comparable'
require 'axiom/types/length_comparable'
Expand Down
43 changes: 9 additions & 34 deletions lib/axiom/types/support/infinity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,12 @@ module Types

# Represent an infinite number
class Infinity
extend Options, DescendantsTracker
include ::Comparable, ::Singleton

# The inverse class
#
# @return [Class<NegativeInfinity>]
#
# @api private
def self.inverse
NegativeInfinity
end
accept_options :inverse, :number

# The numeric representation of infinity
#
# @return [Float]
#
# @api private
def self.number
::Float::INFINITY
end
number ::Float::INFINITY

# Test the number against infinity
#
Expand Down Expand Up @@ -85,24 +72,7 @@ def inverse

# Represent a negative infinite number
class NegativeInfinity < Infinity

# The inverse class
#
# @return [Class<Infinity>]
#
# @api private
def self.inverse
Infinity
end

# The numeric representation of negative infinity
#
# @return [Float]
#
# @api private
def self.number
-::Float::INFINITY
end
number(-::Float::INFINITY)

# Test the number against negative infinity
#
Expand All @@ -120,5 +90,10 @@ def <=>(_other)
end

end # class NegativeInfinity

# Define inverse classes
Infinity.inverse NegativeInfinity
NegativeInfinity.inverse Infinity

end # module Types
end # module Axiom

0 comments on commit 7b30d5e

Please sign in to comment.