Class: Jabber::Bytestreams::IqSiFile
- Inherits:
-
REXML::Element
- Object
- REXML::Element
- 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.
- #typed_add(element) ⇒ Object
Methods inherited from REXML::Element
#delete_elements, #first_element, #first_element_text, #import, import, #replace_element_text
Constructor Details
#initialize(fname = nil, size = nil) ⇒ IqSiFile
Returns a new instance of IqSiFile.
92 93 94 95 96 97 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 92 def initialize(fname=nil, size=nil) super 'file' add_namespace IqSi::PROFILE_FILETRANSFER self.fname = fname self.size = size end |
Instance Method Details
#date ⇒ Object
Get file date
- result
- Time
-
or nil
134 135 136 137 138 139 140 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 134 def date begin Time.xmlschema(attributes['date']) rescue ArgumentError nil end end |
#date=(d) ⇒ Object
Set file date
- d
- Time
-
or nil
145 146 147 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 145 def date=(d) attributes['date'] = (d ? d.xmlschema : nil) end |
#description ⇒ Object
File description
164 165 166 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 164 def description first_element_text('desc') end |
#description=(s) ⇒ Object
Set file description
170 171 172 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 170 def description=(s) replace_element_text('desc', s) end |
#fname ⇒ Object
Get filename (attribute ‘name’)
109 110 111 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 109 def fname attributes['name'] end |
#fname=(s) ⇒ Object
Set filename (attribute ‘name’)
115 116 117 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 115 def fname=(s) attributes['name'] = s end |
#hash ⇒ Object
Get MD5 hash
121 122 123 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 121 def hash attributes['hash'] end |
#hash=(s) ⇒ Object
Set MD5 hash
127 128 129 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 127 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
181 182 183 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 181 def range first_element('range') end |
#size ⇒ Object
File size in bytes
- result
- Fixnum
152 153 154 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 152 def size (attributes['size'] =~ /^\d+$/) ? attributes['size'].to_i : nil end |
#size=(s) ⇒ Object
Set file size
158 159 160 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 158 def size=(s) attributes['size'] = s ? s.to_s : nil end |
#typed_add(element) ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 99 def typed_add(element) if element.kind_of?(REXML::Element) and element.name == 'range' super IqSiFileRange.new.import(element) else super element end end |