Class: Collection
- Inherits:
-
Object
- Object
- Collection
- Defined in:
- lib/collection.rb
Instance Attribute Summary collapse
-
#childCollection ⇒ Object
readonly
descendent collection of the collection.
-
#group ⇒ Object
readonly
owner group of the collection.
-
#name ⇒ Object
readonly
name of the collection.
-
#owner ⇒ Object
readonly
owner of the collection.
-
#permissions ⇒ Object
readonly
permissions of the collection.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Returns instance of collection’s child specified by name.
-
#docs ⇒ Object
Returns string array of all documents in collection.
-
#documents ⇒ Object
Yield each document from collection.
-
#initialize(client, collectionName) ⇒ Collection
constructor
Creates new collection.
-
#to_s ⇒ Object
Returns string of collection.
Constructor Details
#initialize(client, collectionName) ⇒ Collection
Creates new collection.
-
Args :
-
client
-> e.g. ExistAPI.new(“localhost:8080/exist/xmlrpc”, “admin”, “password”) -
collectionName
-> /db/data/cities/
-
-
Returns : -new instance of collection
-
Raises :
-
nothing
->
-
27 28 29 30 31 32 |
# File 'lib/collection.rb', line 27 def initialize(client, collectionName) @client = client load(collectionName) rescue => e raise e end |
Instance Attribute Details
#childCollection ⇒ Object (readonly)
descendent collection of the collection
15 16 17 |
# File 'lib/collection.rb', line 15 def childCollection @childCollection end |
#group ⇒ Object (readonly)
owner group of the collection
11 12 13 |
# File 'lib/collection.rb', line 11 def group @group end |
#name ⇒ Object (readonly)
name of the collection
7 8 9 |
# File 'lib/collection.rb', line 7 def name @name end |
#owner ⇒ Object (readonly)
owner of the collection
9 10 11 |
# File 'lib/collection.rb', line 9 def owner @owner end |
#permissions ⇒ Object (readonly)
permissions of the collection
13 14 15 |
# File 'lib/collection.rb', line 13 def @permissions end |
Instance Method Details
#[](key) ⇒ Object
Returns instance of collection’s child specified by name.
-
Args :
-
key
-> name of the child
-
-
Returns : -instance of collection’s child (document or collection)
-
Raises :
-
nothing
-
84 85 86 87 88 89 |
# File 'lib/collection.rb', line 84 def [](key) @documents.each { |d| return d if key == d.name } return nil end |
#docs ⇒ Object
Returns string array of all documents in collection
-
Args :
-
none
-
-
Returns : -array of strings
-
Raises :
-
nothing
-
69 70 71 72 73 |
# File 'lib/collection.rb', line 69 def docs ds = [] @documents.each{ |d| ds.push(d.name)} return ds end |
#documents ⇒ Object
Yield each document from collection.
-
Args :
-
none
-
-
Returns : -documents
-
Raises :
-
nothing
-
56 57 58 |
# File 'lib/collection.rb', line 56 def documents @documents.each { |d| yield d } end |
#to_s ⇒ Object
Returns string of collection. That inclunde permissions, owner, group and name.
-
Args :
-
none
-
-
Returns : -string of collection
-
Raises :
-
nothing
-
43 44 45 |
# File 'lib/collection.rb', line 43 def to_s() return "#{@permissions} #{@owner} #{@group} #{@name}" end |