Class: XCAPClient::Application
- Inherits:
-
Object
- Object
- XCAPClient::Application
- Defined in:
- lib/xcapclient/application.rb
Instance Attribute Summary collapse
-
#auid ⇒ Object
readonly
Returns the value of attribute auid.
-
#document_name ⇒ Object
readonly
Returns the value of attribute document_name.
-
#mime_type ⇒ Object
readonly
Returns the value of attribute mime_type.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#xmlns ⇒ Object
readonly
Returns the value of attribute xmlns.
Instance Method Summary collapse
-
#add_document(name, scope = nil, xui = nil) ⇒ Object
Creates a new XCAPClient::Document for this application with name document_name, scope scope and xui xui.
-
#document(name = nil, scope = nil, xui = nil) ⇒ Object
Get the XCAPClient::Document with name name, scope scope (:users or :global) belonging to user xui.
-
#documents ⇒ Object
Get an Array containing all the documents created for this application.
-
#initialize(auid, data = {}) ⇒ Application
constructor
:nodoc:.
Constructor Details
#initialize(auid, data = {}) ⇒ Application
:nodoc:
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/xcapclient/application.rb', line 7 def initialize(auid, data={}) #:nodoc: @auid = auid # Check application data. raise ConfigError, "application `data' must be a hash ('#{@auid}')" unless (Hash === data) @xmlns = data[:xmlns].freeze @mime_type = data[:mime_type].freeze # Check auid. raise ConfigError, "application `auid' must be a non empty string ('#{@auid}')" unless String === @auid && ! @auid.empty? # Check xmlns. raise ConfigError, "application `xmlns' must be a non empty string ('#{@auid}')" unless String === @xmlns && ! @xmlns.empty? # Check mime-type. raise ConfigError, "application `mime_type' must be a non empty string ('#{@auid}')" unless String === @mime_type && ! @mime_type.empty? # Create the _documents_ Array. @documents = [] end |
Instance Attribute Details
#auid ⇒ Object (readonly)
Returns the value of attribute auid.
5 6 7 |
# File 'lib/xcapclient/application.rb', line 5 def auid @auid end |
#document_name ⇒ Object (readonly)
Returns the value of attribute document_name.
5 6 7 |
# File 'lib/xcapclient/application.rb', line 5 def document_name @document_name end |
#mime_type ⇒ Object (readonly)
Returns the value of attribute mime_type.
5 6 7 |
# File 'lib/xcapclient/application.rb', line 5 def mime_type @mime_type end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
5 6 7 |
# File 'lib/xcapclient/application.rb', line 5 def scope @scope end |
#xmlns ⇒ Object (readonly)
Returns the value of attribute xmlns.
5 6 7 |
# File 'lib/xcapclient/application.rb', line 5 def xmlns @xmlns end |
Instance Method Details
#add_document(name, scope = nil, xui = nil) ⇒ Object
Creates a new XCAPClient::Document for this application with name document_name, scope scope and xui xui. scope can be :users (default) or :global Symbol. If xui is nil then the documents belongs to our user.
50 51 52 53 54 55 56 |
# File 'lib/xcapclient/application.rb', line 50 def add_document(name, scope=nil, xui=nil) scope = :users unless scope raise DocumentError, "document '#{name}' with scope '#{scope} and xui '#{xui}' already exists" if document(name, scope, xui) @documents << document = Document.new(name, scope, xui) return document end |
#document(name = nil, scope = nil, xui = nil) ⇒ Object
Get the XCAPClient::Document with name name, scope scope (:users or :global) belonging to user xui. If name is nil then the first available document is fetched (careful). If scope is not set then it’s :users by default. If xui is nil then it’s a document owned by us.
34 35 36 37 38 39 40 41 |
# File 'lib/xcapclient/application.rb', line 34 def document(name=nil, scope=nil, xui=nil) scope = :users unless scope if name @documents.find { |doc| doc.name == name and doc.scope == scope and doc.xui == xui } else @documents.first end end |
#documents ⇒ Object
Get an Array containing all the documents created for this application.
44 45 46 |
# File 'lib/xcapclient/application.rb', line 44 def documents @documents end |