Class: Jabber::Bytestreams::IqSiFile
- Inherits:
-
XMPPElement
- Object
- REXML::Element
- XMPPElement
- Jabber::Bytestreams::IqSiFile
- Defined in:
- lib/xmpp4r/bytestreams/iq/si.rb
Overview
File-transfer meta-information, may appear as <file/> in IqSi
Instance Method Summary collapse
-
#date ⇒ Object
- Get file date result
- Time
-
or nil.
-
#date=(d) ⇒ Object
- Set file date d
- Time
-
or nil.
-
#description ⇒ Object
File description.
-
#description=(s) ⇒ Object
Set file description.
-
#fname ⇒ Object
Get filename (attribute ‘name’).
-
#fname=(s) ⇒ Object
Set filename (attribute ‘name’).
-
#hash ⇒ Object
Get MD5 hash.
-
#hash=(s) ⇒ Object
Set MD5 hash.
-
#initialize(fname = nil, size = nil) ⇒ IqSiFile
constructor
A new instance of IqSiFile.
-
#range ⇒ Object
<range/> child.
-
#size ⇒ Object
- File size in bytes result
-
[Fixnum].
-
#size=(s) ⇒ Object
Set file size.
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
#date ⇒ Object
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 |
#description ⇒ Object
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 |
#fname ⇒ Object
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 |
#hash ⇒ Object
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 |
#range ⇒ Object
<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 |
#size ⇒ Object
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 |