Class: Jabber::Bytestreams::IqSiFile

Inherits:
XMPPElement show all
Defined in:
lib/xmpp4r/bytestreams/iq/si.rb

Overview

File-transfer meta-information, may appear as <file/> in IqSi

Instance Method Summary collapse

Methods inherited from XMPPElement

class_for_name_xmlns, #clone, force_xmlns, force_xmlns?, import, name_xmlns, name_xmlns_for_class, #parent=, #set_xml_lang, #typed_add, #xml_lang, #xml_lang=

Methods inherited from REXML::Element

#==, #delete_elements, #each_elements, #first_element, #first_element_content, #first_element_text, #import, import, #replace_element_content, #replace_element_text, #typed_add

Constructor Details

#initialize(fname = nil, size = nil) ⇒ IqSiFile

Returns a new instance of IqSiFile.



85
86
87
88
89
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 85

def initialize(fname=nil, size=nil)
  super()
  self.fname = fname
  self.size = size
end

Instance Method Details

#dateObject

Get file date

result
Time

or nil



118
119
120
121
122
123
124
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 118

def date
  begin
    Time.xmlschema(attributes['date'])
  rescue ArgumentError
    nil
  end
end

#date=(d) ⇒ Object

Set file date

d
Time

or nil



129
130
131
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 129

def date=(d)
  attributes['date'] = (d ? d.xmlschema : nil)
end

#descriptionObject

File description



148
149
150
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 148

def description
  first_element_text('desc')
end

#description=(s) ⇒ Object

Set file description



154
155
156
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 154

def description=(s)
  replace_element_text('desc', s)
end

#fnameObject

Get filename (attribute ‘name’)



93
94
95
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 93

def fname
  attributes['name']
end

#fname=(s) ⇒ Object

Set filename (attribute ‘name’)



99
100
101
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 99

def fname=(s)
  attributes['name'] = s
end

#hashObject

Get MD5 hash



105
106
107
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 105

def hash
  attributes['hash']
end

#hash=(s) ⇒ Object

Set MD5 hash



111
112
113
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 111

def hash=(s)
  attributes['hash'] = s
end

#rangeObject

<range/> child

A file-transfer offer may contain this with no attributes set, indicating the ability to do ranged transfers.

result
IqSiFileRange


165
166
167
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 165

def range
  first_element('range')
end

#sizeObject

File size in bytes

result
Fixnum


136
137
138
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 136

def size
  (attributes['size'] =~ /^\d+$/) ? attributes['size'].to_i : nil
end

#size=(s) ⇒ Object

Set file size



142
143
144
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 142

def size=(s)
  attributes['size'] = s ? s.to_s : nil
end