class Jabber::MUC::HipChat::Presence

Public Class Methods

new(my_jid) click to toggle source
Calls superclass method
# File lib/xmpp4r/muc/hipchat/presence.rb, line 5
def initialize my_jid
  super(:chat)
  @my_jid   = my_jid
  self.from = my_jid
end

Public Instance Methods

get_join(jid, fetch_history = false) click to toggle source
# File lib/xmpp4r/muc/hipchat/presence.rb, line 15
def get_join jid, fetch_history = false
  get_status(:available, room_jid(jid)) # TODO: Handle all join responses
end
get_leave(jid, reason = nil) click to toggle source
# File lib/xmpp4r/muc/hipchat/presence.rb, line 11
def get_leave jid, reason = nil
  get_status(:unavailable, room_jid(jid), reason)
end
get_status(type, to = nil, status = nil, fetch_history = false) click to toggle source
# File lib/xmpp4r/muc/hipchat/presence.rb, line 19
def get_status type, to = nil, status = nil, fetch_history = false
  self.dup.tap do |d|
    d.set_status(status)
    d.set_type(type)
    d.no_history! unless fetch_history
    d.to = to
  end
end
no_history!() click to toggle source
# File lib/xmpp4r/muc/hipchat/presence.rb, line 28
def no_history!
  element = REXML::Element.new('history').tap do |h|
    h.add_attribute('maxstanzas', '0')
  end

  xmuc = XMUC.new
  xmuc.add_element(element)
  self.add(xmuc)
end
send_to(stream, &block) click to toggle source
# File lib/xmpp4r/muc/hipchat/presence.rb, line 38
def send_to stream, &block
  stream.send(self, &block)
end

Private Instance Methods

room_jid(jid) click to toggle source
# File lib/xmpp4r/muc/hipchat/presence.rb, line 44
def room_jid jid
  JID.new(jid).tap do |j|
    j.resource = @my_jid.resource
  end
end