lib/blather/roster_item.rb in blather-0.4.16 vs lib/blather/roster_item.rb in blather-0.5.0

- old
+ new

@@ -1,19 +1,21 @@ module Blather # RosterItems hold internal representations of the user's roster # including each JID's status. class RosterItem + # @private VALID_SUBSCRIPTION_TYPES = [:both, :from, :none, :remove, :to].freeze attr_reader :jid, :ask, :statuses attr_accessor :name, :groups + # @private def self.new(item) return item if item.is_a?(self) super end @@ -116,21 +118,29 @@ r.query << n n.groups = groups r end - def <=>(o) - self.jid.to_s <=> o.jid.to_s + # Compare two RosterItems by their JID + # + # @param [Blather::JID] other the JID to compare against + # @return [Fixnum<-1, 0, 1>] + def <=>(other) + JID.new(self.jid) <=> JID.new(other.jid) end # Compare two RosterItem objects by name, type and category # @param [RosterItem] o the Identity object to compare against # @return [true, false] def eql?(o, *fields) o.is_a?(self.class) && o.jid == self.jid && o.groups == self.groups end - alias_method :==, :eql? + + # @private + def ==(o) + eql?(o) + end end #RosterItem end