Class: Grendel::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/grendel/document.rb

Direct Known Subclasses

LinkedDocument

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, params) ⇒ Document

Returns a new instance of Document.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/grendel/document.rb', line 5

def initialize(user, params)
  params = Mash.new(params)
  @user = user
  @client = user.client
  @name = params[:name]
  @data = params[:data]
  @content_type = params[:content_type]
  @uri = params[:uri] ?
    URI.parse(params[:uri]).path :
    "/documents/" + @name # escape this?
end

Instance Attribute Details

#content_typeObject

Returns the value of attribute content_type.



3
4
5
# File 'lib/grendel/document.rb', line 3

def content_type
  @content_type
end

#dataObject

Returns the value of attribute data.



3
4
5
# File 'lib/grendel/document.rb', line 3

def data
  @data
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/grendel/document.rb', line 3

def name
  @name
end

#uriObject

Returns the value of attribute uri.



3
4
5
# File 'lib/grendel/document.rb', line 3

def uri
  @uri
end

#userObject

Returns the value of attribute user.



3
4
5
# File 'lib/grendel/document.rb', line 3

def user
  @user
end

Instance Method Details

#deleteObject

delete this document from Grendel



18
19
20
# File 'lib/grendel/document.rb', line 18

def delete
  @user.delete(@uri)
end

send link operations to the Link class



23
24
25
# File 'lib/grendel/document.rb', line 23

def links
  LinkManager.new(self)
end