module Blather::Stanza::Presence::Status::InstanceMethods

Public Instance Methods

<=>(o) click to toggle source

Compare status based on priority and state: unavailable status is always less valuable than others Raises an error if the JIDs aren't the same

@param [Blather::Stanza::Presence::Status] o @return [true,false]

# File lib/blather/stanza/presence/status.rb, line 199
def <=>(o)
  if self.from || o.from
    unless self.from.stripped == o.from.stripped
      raise ArgumentError, "Cannot compare status from different JIDs: #{[self.from, o.from].inspect}"
    end
  end

  if (self.type.nil? && o.type.nil?) || (!self.type.nil? && !o.type.nil?)
    if self.priority == o.priority
      POSSIBLE_STATES.index(self.state) <=> POSSIBLE_STATES.index(o.state)
    else
      self.priority <=> o.priority
    end
  elsif self.type.nil? && !o.type.nil?
    1
  elsif !self.type.nil? && o.type.nil?
    -1
  end
end
available?() click to toggle source

Check if the state is available

@return [true, false]

# File lib/blather/stanza/presence/status.rb, line 106
def available?
  self.state == :available
end
away?() click to toggle source

Check if the state is away

@return [true, false]

# File lib/blather/stanza/presence/status.rb, line 113
def away?
  self.state == :away
end
chat?() click to toggle source

Check if the state is chat

@return [true, false]

# File lib/blather/stanza/presence/status.rb, line 120
def chat?
  self.state == :chat
end
dnd?() click to toggle source

Check if the state is dnd

@return [true, false]

# File lib/blather/stanza/presence/status.rb, line 127
def dnd?
  self.state == :dnd
end
message() click to toggle source

Get the status message

@return [String, nil]

# File lib/blather/stanza/presence/status.rb, line 182
def message
  read_content :status
end
message=(message) click to toggle source

Set the status message

@param [String, nil] message

# File lib/blather/stanza/presence/status.rb, line 189
def message=(message)
  set_content_for :status, message
end
priority() click to toggle source

Get the priority of the status

@return [Fixnum<-128…127>]

# File lib/blather/stanza/presence/status.rb, line 175
def priority
  read_content(:priority).to_i
end
state() click to toggle source

Get the state of the status

@return [<:available, :away, :chat, :dnd, :xa>]

# File lib/blather/stanza/presence/status.rb, line 155
def state
  state = type || content_from(:show)
  state = :available if state.blank?
  state.to_sym
end
xa?() click to toggle source

Check if the state is xa

@return [true, false]

# File lib/blather/stanza/presence/status.rb, line 134
def xa?
  self.state == :xa
end