Class: Blather::Stanza::Iq::Si::Si

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

Overview

Si stanza fragment

Defined Under Namespace

Classes: Feature, File, Range

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

.find_or_create(parent) ⇒ Si::Si

Find or create si node in Si Iq and converts it to Si::Si

Parameters:

  • parent (Si)

    a Si Iq where to find or create si

Returns:



103
104
105
106
107
108
109
110
111
112
113
# File 'lib/blather/stanza/iq/si.rb', line 103

def self.find_or_create(parent)
  if found_si = parent.find_first('//ns:si', :ns => NS_SI)
    si = self.new found_si
    found_si.remove
  else
    si = self.new
  end
  parent << si

  si
end

.new(node = nil) ⇒ Si::Si

Create a new Si::Si object

Parameters:

  • node (XML::Node, nil) (defaults to: nil)

    a node to inherit from

Returns:



91
92
93
94
95
96
# File 'lib/blather/stanza/iq/si.rb', line 91

def self.new(node = nil)
  new_node = super :si
  new_node.namespace = NS_SI
  new_node.inherit node if node
  new_node
end

Instance Method Details

#featureSi::Si::Feature

Find or create feature node

Returns:



167
168
169
# File 'lib/blather/stanza/iq/si.rb', line 167

def feature
  Feature.find_or_create self
end

#fileSi::Si::File

Find or create file node

Returns:



160
161
162
# File 'lib/blather/stanza/iq/si.rb', line 160

def file
  File.find_or_create self
end

#idString?

Get the id of the stream

Returns:

  • (String, nil)


118
119
120
# File 'lib/blather/stanza/iq/si.rb', line 118

def id
  read_attr :id
end

#id=(id) ⇒ Object

Set the id

Parameters:

  • id (String, nil)

    the id of the stream



125
126
127
# File 'lib/blather/stanza/iq/si.rb', line 125

def id=(id)
  write_attr :id, id
end

#mime_typeString?

Get the MIME type of the stream

Returns:

  • (String, nil)


132
133
134
# File 'lib/blather/stanza/iq/si.rb', line 132

def mime_type
  read_attr 'mime-type'
end

#mime_type=(type) ⇒ Object

Set the MIME type

Parameters:

  • type (String, nil)

    the MIME type of the stream



139
140
141
# File 'lib/blather/stanza/iq/si.rb', line 139

def mime_type=(type)
  write_attr 'mime-type', type
end

#profileString?

Get the profile of the stream

Returns:

  • (String, nil)


146
147
148
# File 'lib/blather/stanza/iq/si.rb', line 146

def profile
  read_attr :profile
end

#profile=(profile) ⇒ Object

Set the profile

Parameters:

  • profile (String, nil)

    the profile of the stream



153
154
155
# File 'lib/blather/stanza/iq/si.rb', line 153

def profile=(profile)
  write_attr :profile, profile
end