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

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

Create a new S5b::StreamHost

Overloads:

  • + (Object) new(node)

    Create a new StreamHost by inheriting an existing node

  • + (Object) new(opts)

    Create a new StreamHost through a hash of 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

  • + (Object) new(jid, host = nil, port = nil)

    Create a new 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

- (String?) host

Get the host address of the streamhost



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

def host
  read_attr :host
end

- (Object) host=(h)

Set the host address of the streamhost



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

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

- (Blather::JID?) jid

Get the jid of the streamhost



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

- (Object) jid=(j)

Set the jid of the streamhost



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

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

- (Fixnum?) port

Get the port of the streamhost



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

- (Object) port=(p)

Set the port of the streamhost



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

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