Class: Chickadee::NumericID
- Inherits:
-
Object
- Object
- Chickadee::NumericID
- Includes:
- Comparable
- Defined in:
- lib/chickadee/vos/numeric_id.rb
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(id) ⇒ NumericID
constructor
A new instance of NumericID.
- #to_i ⇒ Object
Constructor Details
#initialize(id) ⇒ NumericID
Returns a new instance of NumericID.
5 6 7 8 |
# File 'lib/chickadee/vos/numeric_id.rb', line 5 def initialize(id) raise(ArgumentError, "invalid id: #{id}") unless id.is_a?(Integer) && id > 0 @id = id end |
Instance Method Details
#<=>(other) ⇒ Object
14 15 16 |
# File 'lib/chickadee/vos/numeric_id.rb', line 14 def <=>(other) self.to_i <=> other.to_i end |
#==(other) ⇒ Object
18 19 20 |
# File 'lib/chickadee/vos/numeric_id.rb', line 18 def ==(other) self.class == other.class && self.hash == other.hash end |
#eql?(other) ⇒ Boolean
22 23 24 |
# File 'lib/chickadee/vos/numeric_id.rb', line 22 def eql?(other) self == other end |
#hash ⇒ Object
26 27 28 |
# File 'lib/chickadee/vos/numeric_id.rb', line 26 def hash @id.hash end |
#to_i ⇒ Object
10 11 12 |
# File 'lib/chickadee/vos/numeric_id.rb', line 10 def to_i @id end |