Class: Document
- Inherits:
-
Object
- Object
- Document
- Defined in:
- lib/document.rb
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
owner group of the document.
-
#name ⇒ Object
readonly
name of the document.
-
#owner ⇒ Object
readonly
owner of the document.
-
#path ⇒ Object
readonly
path of the document.
-
#permissions ⇒ Object
readonly
permissions of the document.
Instance Method Summary collapse
-
#content ⇒ Object
Returns content of document in db.
-
#initialize(client, hash, colname) ⇒ Document
constructor
Creates new instance of document.
-
#to_s ⇒ Object
Returns string of document.
Constructor Details
#initialize(client, hash, colname) ⇒ Document
Creates new instance of document
-
Args :
-
client
-> e.g. ExistAPI.new(“localhost:8080/exist/xmlrpc”, “admin”, “password”) -
hash
-> hash, name -> “name of the document” -
colname
-> name of the collection
-
-
Returns : -instance of document
-
Raises :
-
nothing
-
-
Example :
-
Document.new(api, hash, collection_path)
-
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/document.rb', line 26 def initialize(client, hash, colname) @client = client @path = colname + hash['name'] @name = @path[/[^\/]+$/] #puts "filename #{@name}" @owner = hash['owner'] @group = hash['group'] @permissions = hash['permissions'] rescue => e raise e end |
Instance Attribute Details
#group ⇒ Object (readonly)
owner group of the document
10 11 12 |
# File 'lib/document.rb', line 10 def group @group end |
#name ⇒ Object (readonly)
name of the document
6 7 8 |
# File 'lib/document.rb', line 6 def name @name end |
#owner ⇒ Object (readonly)
owner of the document
8 9 10 |
# File 'lib/document.rb', line 8 def owner @owner end |
#path ⇒ Object (readonly)
path of the document
4 5 6 |
# File 'lib/document.rb', line 4 def path @path end |
#permissions ⇒ Object (readonly)
permissions of the document
12 13 14 |
# File 'lib/document.rb', line 12 def @permissions end |
Instance Method Details
#content ⇒ Object
Returns content of document in db. Usually document is xml. Retrieves a document from the database.
-
Args :
-
none
-
-
Returns :
-
the result of call
-
-
Raises :
-
ExistException
-> Failed to load content of Document
-
60 61 62 63 64 65 66 67 68 |
# File 'lib/document.rb', line 60 def content = { "indent" => "yes", "encoding" => "UTF-8", "expand-xincludes" => "yes" } return @client.call("getDocument", @path, ) rescue XMLRPC::FaultException => e raise e rescue raise ExistException.new("Failed to load content of Document", 11), callers end |
#to_s ⇒ Object
Returns string of document. That inclunde permissions, owner, group and name.
-
Args :
-
none
-
-
Returns : -string of collection
-
Raises :
-
nothing
-
47 48 49 |
# File 'lib/document.rb', line 47 def to_s return "#{@permissions} #{@owner} #{@group} #{@name}" end |