Class: Jabber::Bytestreams::IqSiFileRange

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

Overview

Information for ranged transfers

Instance Method Summary collapse

Methods inherited from REXML::Element

#delete_elements, #first_element, #first_element_text, import, #import, #replace_element_text, #typed_add

Constructor Details

#initialize(offset = nil, length = nil) ⇒ IqSiFileRange

Returns a new instance of IqSiFileRange


193
194
195
196
197
198
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 193

def initialize(offset=nil, length=nil)
  super('range')

  self.offset = offset
  self.length = length
end

Instance Method Details

#lengthObject

File length (if not to transfer whole file)


214
215
216
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 214

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

#length=(o) ⇒ Object

Set file length


220
221
222
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 220

def length=(o)
  attributes['length'] = (o ? o.to_s : nil)
end

#offsetObject

File offset (for continuing an interrupted transfer)


202
203
204
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 202

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

#offset=(o) ⇒ Object

Set file offset


208
209
210
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 208

def offset=(o)
  attributes['offset'] = (o ? o.to_s : nil)
end