Class: Blather::Stanza::Iq::S5b::StreamHost

Inherits:
XMPPNode
  • Object
show all
Defined in:
lib/blather/stanza/iq/s5b.rb

Overview

StreamHost Stanza

Constant Summary

Constant Summary

Constants inherited from XMPPNode

XMPPNode::BASE_NAMES

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from XMPPNode

class_from_registration, #decorate, decorator_modules, import, parse, register, #to_stanza

Class Method Details

.new(node) ⇒ Object .new(opts) ⇒ Object .new(jid, host = nil, port = nil) ⇒ Object

Create a new S5b::StreamHost

Overloads:

  • .new(node) ⇒ Object

    Create a new StreamHost by inheriting an existing node

    Parameters:

    • node (XML::Node)

      an XML::Node to inherit from

  • .new(opts) ⇒ Object

    Create a new StreamHost through a hash of options

    Parameters:

    • opts (Hash)

      a hash options

    Options Hash (opts):

    • :jid (Blather::JID, String)

      the JID of the StreamHost

    • :host (#to_s)

      the host the StreamHost

    • :port (#to_s)

      the post of the StreamHost

  • .new(jid, host = nil, port = nil) ⇒ Object

    Create a new StreamHost

    Parameters:

    • jid (Blather::JID, String)

      the JID of the StreamHost

    • host (#to_s)

      the host the StreamHost

    • port (#to_s)

      the post of the StreamHost



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/blather/stanza/iq/s5b.rb', line 88

def self.new(jid, host = nil, port = nil)
  new_node = super 'streamhost'

  case jid
  when Nokogiri::XML::Node
    new_node.inherit jid
  when Hash
    new_node.jid = jid[:jid]
    new_node.host = jid[:host]
    new_node.port = jid[:port]
  else
    new_node.jid = jid
    new_node.host = host
    new_node.port = port
  end
  new_node
end

Instance Method Details

#hostString?

Get the host address of the streamhost

Returns:

  • (String, nil)


127
128
129
# File 'lib/blather/stanza/iq/s5b.rb', line 127

def host
  read_attr :host
end

#host=(h) ⇒ Object

Set the host address of the streamhost

Parameters:

  • (String, nil)


134
135
136
# File 'lib/blather/stanza/iq/s5b.rb', line 134

def host=(h)
  write_attr :host, h
end

#jidBlather::JID?

Get the jid of the streamhost

Returns:



109
110
111
112
113
114
115
# File 'lib/blather/stanza/iq/s5b.rb', line 109

def jid
  if j = read_attr(:jid)
    JID.new(j)
  else
    nil
  end
end

#jid=(j) ⇒ Object

Set the jid of the streamhost

Parameters:



120
121
122
# File 'lib/blather/stanza/iq/s5b.rb', line 120

def jid=(j)
  write_attr :jid, (j ? j.to_s : nil)
end

#portFixnum?

Get the port of the streamhost

Returns:

  • (Fixnum, nil)


141
142
143
144
145
146
147
# File 'lib/blather/stanza/iq/s5b.rb', line 141

def port
  if p = read_attr(:port)
    p.to_i
  else
    nil
  end
end

#port=(p) ⇒ Object

Set the port of the streamhost

Parameters:

  • (String, Fixnum, nil)


152
153
154
# File 'lib/blather/stanza/iq/s5b.rb', line 152

def port=(p)
  write_attr :port, p
end