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.
96 97 98 99 100 101 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 96 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
138 139 140 141 142 143 144 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 138 def date begin Time.xmlschema(attributes['date']) rescue ArgumentError nil end end |
#date=(d) ⇒ Object
Set file date
- d
- Time
-
or nil
149 150 151 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 149 def date=(d) attributes['date'] = (d ? d.xmlschema : nil) end |
#description ⇒ Object
File description
168 169 170 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 168 def description first_element_text('desc') end |
#description=(s) ⇒ Object
Set file description
174 175 176 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 174 def description=(s) replace_element_text('desc', s) end |
#fname ⇒ Object
Get filename (attribute ‘name’)
113 114 115 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 113 def fname attributes['name'] end |
#fname=(s) ⇒ Object
Set filename (attribute ‘name’)
119 120 121 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 119 def fname=(s) attributes['name'] = s end |
#hash ⇒ Object
Get MD5 hash
125 126 127 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 125 def hash attributes['hash'] end |
#hash=(s) ⇒ Object
Set MD5 hash
131 132 133 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 131 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
185 186 187 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 185 def range first_element('range') end |
#size ⇒ Object
File size in bytes
- result
- Fixnum
156 157 158 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 156 def size (attributes['size'] =~ /^\d+$/) ? attributes['size'].to_i : nil end |
#size=(s) ⇒ Object
Set file size
162 163 164 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 162 def size=(s) attributes['size'] = s ? s.to_s : nil end |
#typed_add(element) ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/xmpp4r/bytestreams/iq/si.rb', line 103 def typed_add(element) if element.kind_of?(REXML::Element) and element.name == 'range' super IqSiFileRange.new.import(element) else super element end end |