Class: Gdoc::Document
- Inherits:
-
Object
- Object
- Gdoc::Document
- Defined in:
- lib/gdoc/document.rb
Instance Attribute Summary (collapse)
-
- (Object) author
Returns the value of attribute author.
-
- (Object) doc_id
Returns the value of attribute doc_id.
-
- (Object) href
Returns the value of attribute href.
-
- (Object) last_modified_by
Returns the value of attribute last_modified_by.
-
- (Object) last_updated
Returns the value of attribute last_updated.
-
- (Object) last_viewed
Returns the value of attribute last_viewed.
-
- (Object) links
Returns the value of attribute links.
-
- (Object) parent
Returns the value of attribute parent.
-
- (Object) permissions
readonly
Returns the value of attribute permissions.
-
- (Object) title
Returns the value of attribute title.
-
- (Object) type
Returns the value of attribute type.
-
- (Object) writers_can_invite
Returns the value of attribute writers_can_invite.
-
- (Object) xml
readonly
Returns the value of attribute xml.
Instance Method Summary (collapse)
- - (Object) <=>(document)
- - (Object) add_permission(email, role)
-
- (Object) full_title
Full title, including parent folder path.
-
- (Document) initialize(title, options = {})
constructor
Initializer.
- - (Object) inspect
- - (Object) to_s
- - (Object) to_xml
Constructor Details
- (Document) initialize(title, options = {})
Initializer.
Args: - title: string Title of the document - options: hash of options valid options: * +type+: string The type of document. Possible values are 'document', 'presentation', 'spreadsheet', 'folder', 'pdf' * +last_updated+: DateTime * +xml+: string An XML representation of this doc * +parent+: containing folder
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/gdoc/document.rb', line 45 def initialize(title, ={}) @title = title @links = {} @type = [:type] || '' @last_updated = [:last_updated] || DateTime.new @last_viewed = [:last_viewed] || DateTime.new @xml = [:xml] || nil @permissions = {'owner' => [], 'reader' => [], 'writer' => []} @parent = [:parent] || nil end |
Instance Attribute Details
- (Object) author
Returns the value of attribute author
30 31 32 |
# File 'lib/gdoc/document.rb', line 30 def @author end |
- (Object) doc_id
Returns the value of attribute doc_id
30 31 32 |
# File 'lib/gdoc/document.rb', line 30 def doc_id @doc_id end |
- (Object) href
Returns the value of attribute href
30 31 32 |
# File 'lib/gdoc/document.rb', line 30 def href @href end |
- (Object) last_modified_by
Returns the value of attribute last_modified_by
30 31 32 |
# File 'lib/gdoc/document.rb', line 30 def last_modified_by @last_modified_by end |
- (Object) last_updated
Returns the value of attribute last_updated
30 31 32 |
# File 'lib/gdoc/document.rb', line 30 def last_updated @last_updated end |
- (Object) last_viewed
Returns the value of attribute last_viewed
30 31 32 |
# File 'lib/gdoc/document.rb', line 30 def last_viewed @last_viewed end |
- (Object) links
Returns the value of attribute links
30 31 32 |
# File 'lib/gdoc/document.rb', line 30 def links @links end |
- (Object) parent
Returns the value of attribute parent
30 31 32 |
# File 'lib/gdoc/document.rb', line 30 def parent @parent end |
- (Object) permissions (readonly)
Returns the value of attribute permissions
29 30 31 |
# File 'lib/gdoc/document.rb', line 29 def @permissions end |
- (Object) title
Returns the value of attribute title
30 31 32 |
# File 'lib/gdoc/document.rb', line 30 def title @title end |
- (Object) type
Returns the value of attribute type
30 31 32 |
# File 'lib/gdoc/document.rb', line 30 def type @type end |
- (Object) writers_can_invite
Returns the value of attribute writers_can_invite
30 31 32 |
# File 'lib/gdoc/document.rb', line 30 def writers_can_invite @writers_can_invite end |
- (Object) xml (readonly)
Returns the value of attribute xml
29 30 31 |
# File 'lib/gdoc/document.rb', line 29 def xml @xml end |
Instance Method Details
- (Object) <=>(document)
77 78 79 |
# File 'lib/gdoc/document.rb', line 77 def <=>(document) @title.casecmp(document.title) # need case-insensitive version of <=> end |
- (Object) add_permission(email, role)
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/gdoc/document.rb', line 56 def (email, role) role.downcase! return if !@permissions.has_key?(role) if email.class == String @permissions[role].push(email) elsif email.class == Array @permissions[role] = @permissions[role] | email end @permissions[role].uniq! end |
- (Object) full_title
Full title, including parent folder path
69 70 71 72 73 74 75 |
# File 'lib/gdoc/document.rb', line 69 def full_title t = "" if parent t = parent.full_title + "/" end return t + title end |
- (Object) inspect
91 92 93 |
# File 'lib/gdoc/document.rb', line 91 def inspect self.to_s end |
- (Object) to_s
81 82 83 84 85 |
# File 'lib/gdoc/document.rb', line 81 def to_s [@title, ", doc_id: #{@doc_id} (#{@type})", "\nlinks: #{@links.inspect}", "\npermissions:\n#{@permissions.inspect}"].join end |
- (Object) to_xml
87 88 89 |
# File 'lib/gdoc/document.rb', line 87 def to_xml @xml end |