Class: RestfulSharePoint::File

Inherits:
Object show all
Defined in:
lib/restful-sharepoint/objects/file.rb

Direct Known Subclasses

Attachment

Constant Summary

Constants inherited from Object

Object::DEFAULT_OPTIONS

Instance Attribute Summary

Attributes inherited from Object

#connection, #options, #properties

Instance Method Summary collapse

Methods inherited from Object

#==, #[], #each, #eql?, #fetch_deferred, #initialize, #to_h, #to_json

Constructor Details

This class inherits a constructor from RestfulSharePoint::Object

Instance Method Details

#contentObject



8
9
10
# File 'lib/restful-sharepoint/objects/file.rb', line 8

def content
  @content ||= connection.get(url)
end

#endpointObject



4
5
6
# File 'lib/restful-sharepoint/objects/file.rb', line 4

def endpoint
  "#{@parent.endpoint}/File"
end

#extensionObject



31
32
33
# File 'lib/restful-sharepoint/objects/file.rb', line 31

def extension
  self['ServerRelativeUrl'].rpartition('.').last
end

#filenameObject



27
28
29
# File 'lib/restful-sharepoint/objects/file.rb', line 27

def filename
  self['ServerRelativeUrl'].rpartition('/').last
end

#nameObject



23
24
25
# File 'lib/restful-sharepoint/objects/file.rb', line 23

def name
  filename.rpartition('.').first
end

#sizeObject

In bytes



19
20
21
# File 'lib/restful-sharepoint/objects/file.rb', line 19

def size
  self['Length'] || content.length
end

#urlObject



12
13
14
15
16
# File 'lib/restful-sharepoint/objects/file.rb', line 12

def url
  url = URI.parse(connection.site_url)
  url.path = Addressable::URI.encode(self['ServerRelativeUrl'])
  url.to_s
end