Class: Blather::Stanza::Iq::Si::Si::File
- Defined in:
- lib/blather/stanza/iq/si.rb
Overview
File stanza fragment
Constant Summary
Constants inherited from XMPPNode
Class Method Summary collapse
-
.find_or_create(parent) ⇒ Si::Si::File
Find or create file node in si node and converts it to Si::Si::File.
-
.new(name = nil, size = nil) ⇒ Si::Si::File
Create a new Si::Si::File object.
Instance Method Summary collapse
-
#date ⇒ Time?
Get the date.
-
#date=(date) ⇒ Object
Set the date.
-
#desc ⇒ String?
Get the desc.
-
#desc=(desc) ⇒ Object
Set the desc.
-
#hash ⇒ String?
Get the hash.
-
#hash=(hash) ⇒ Object
Set the hash.
-
#name ⇒ String?
Get the filename.
-
#name=(name) ⇒ Object
Set the filename.
-
#range ⇒ Si::Si::File::Range
Find or create range node.
-
#size ⇒ Fixnum?
Get the size.
-
#size=(size) ⇒ Object
Set the size.
Methods inherited from XMPPNode
class_from_registration, #decorate, decorator_modules, import, parse, register, #to_stanza
Class Method Details
.find_or_create(parent) ⇒ Si::Si::File
Find or create file node in si node and converts it to Si::Si::File
239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/blather/stanza/iq/si.rb', line 239 def self.find_or_create(parent) if found_file = parent.find_first('//ns:file', :ns => self.registered_ns) file = self.new found_file found_file.remove else file = self.new end parent << file file end |
.new(name = nil, size = nil) ⇒ Si::Si::File
Create a new Si::Si::File object
221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/blather/stanza/iq/si.rb', line 221 def self.new(name = nil, size = nil) new_node = super :file case name when Nokogiri::XML::Node new_node.inherit name else new_node.name = name new_node.size = size end new_node end |
Instance Method Details
#date ⇒ Time?
Get the date
282 283 284 285 286 287 288 |
# File 'lib/blather/stanza/iq/si.rb', line 282 def date begin Time.xmlschema(read_attr(:date)) rescue ArgumentError nil end end |
#date=(date) ⇒ Object
Set the date
293 294 295 |
# File 'lib/blather/stanza/iq/si.rb', line 293 def date=(date) write_attr :date, (date ? date.xmlschema : nil) end |
#desc ⇒ String?
Get the desc
318 319 320 |
# File 'lib/blather/stanza/iq/si.rb', line 318 def desc content_from 'ns:desc', :ns => self.class.registered_ns end |
#desc=(desc) ⇒ Object
Set the desc
325 326 327 |
# File 'lib/blather/stanza/iq/si.rb', line 325 def desc=(desc) set_content_for :desc, desc end |
#hash ⇒ String?
Get the hash
268 269 270 |
# File 'lib/blather/stanza/iq/si.rb', line 268 def hash read_attr :hash end |
#hash=(hash) ⇒ Object
Set the hash
275 276 277 |
# File 'lib/blather/stanza/iq/si.rb', line 275 def hash=(hash) write_attr :hash, hash end |
#name ⇒ String?
Get the filename
254 255 256 |
# File 'lib/blather/stanza/iq/si.rb', line 254 def name read_attr :name end |
#name=(name) ⇒ Object
Set the filename
261 262 263 |
# File 'lib/blather/stanza/iq/si.rb', line 261 def name=(name) write_attr :name, name end |
#range ⇒ Si::Si::File::Range
Find or create range node
332 333 334 |
# File 'lib/blather/stanza/iq/si.rb', line 332 def range Range.find_or_create self end |
#size ⇒ Fixnum?
Get the size
300 301 302 303 304 305 306 |
# File 'lib/blather/stanza/iq/si.rb', line 300 def size if (s = read_attr(:size)) && (s =~ /^\d+$/) s.to_i else nil end end |
#size=(size) ⇒ Object
Set the size
311 312 313 |
# File 'lib/blather/stanza/iq/si.rb', line 311 def size=(size) write_attr :size, size end |