Class: Ice::Identity
- Inherits:
-
Object
- Object
- Ice::Identity
- Defined in:
- lib/Ice.rb,
lib/Ice/Identity.rb
Overview
Reopen Identity to add the <=> method.
Instance Attribute Summary collapse
-
#category ⇒ Object
Returns the value of attribute category.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(name = '', category = '') ⇒ Identity
constructor
A new instance of Identity.
- #inspect ⇒ Object
Constructor Details
#initialize(name = '', category = '') ⇒ Identity
Returns a new instance of Identity.
28 29 30 31 |
# File 'lib/Ice/Identity.rb', line 28 def initialize(name='', category='') @name = name @category = category end |
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
55 56 57 |
# File 'lib/Ice/Identity.rb', line 55 def category @category end |
#name ⇒ Object
Returns the value of attribute name.
55 56 57 |
# File 'lib/Ice/Identity.rb', line 55 def name @name end |
Instance Method Details
#<=>(other) ⇒ Object
230 231 232 233 234 235 236 237 |
# File 'lib/Ice.rb', line 230 def <=>(other) n = self.name <=> other.name if n == 0 return self.category <=> other.category else return n end end |
#==(other) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/Ice/Identity.rb', line 40 def ==(other) return false if !other.is_a? ::Ice::Identity or @name != other.name or @category != other.category true end |
#eql?(other) ⇒ Boolean
47 48 49 |
# File 'lib/Ice/Identity.rb', line 47 def eql?(other) return other.class == self.class && other == self end |
#hash ⇒ Object
33 34 35 36 37 38 |
# File 'lib/Ice/Identity.rb', line 33 def hash _h = 0 _h = 5 * _h + @name.hash _h = 5 * _h + @category.hash _h % 0x7fffffff end |
#inspect ⇒ Object
51 52 53 |
# File 'lib/Ice/Identity.rb', line 51 def inspect ::Ice::__stringify(self, T_Identity) end |