Class: Skydrive::File
- Inherits:
-
Object
- Object
- Skydrive::File
- Defined in:
- lib/skydrive/file.rb
Instance Attribute Summary collapse
-
#content_tag ⇒ Object
Returns the value of attribute content_tag.
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#file_size ⇒ Object
Returns the value of attribute file_size.
-
#homework_submission_url ⇒ Object
Returns the value of attribute homework_submission_url.
-
#icon ⇒ Object
Returns the value of attribute icon.
-
#is_embeddable ⇒ Object
Returns the value of attribute is_embeddable.
-
#is_image ⇒ Object
Returns the value of attribute is_image.
-
#is_text ⇒ Object
Returns the value of attribute is_text.
-
#is_video ⇒ Object
Returns the value of attribute is_video.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#mime_comment ⇒ Object
Returns the value of attribute mime_comment.
-
#name ⇒ Object
Returns the value of attribute name.
-
#server_relative_url ⇒ Object
Returns the value of attribute server_relative_url.
-
#suffix ⇒ Object
Returns the value of attribute suffix.
-
#time_created ⇒ Object
Returns the value of attribute time_created.
-
#time_last_modified ⇒ Object
Returns the value of attribute time_last_modified.
-
#title ⇒ Object
Returns the value of attribute title.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
Instance Attribute Details
#content_tag ⇒ Object
Returns the value of attribute content_tag.
5 6 7 |
# File 'lib/skydrive/file.rb', line 5 def content_tag @content_tag end |
#content_type ⇒ Object
Returns the value of attribute content_type.
5 6 7 |
# File 'lib/skydrive/file.rb', line 5 def content_type @content_type end |
#file_size ⇒ Object
Returns the value of attribute file_size.
5 6 7 |
# File 'lib/skydrive/file.rb', line 5 def file_size @file_size end |
#homework_submission_url ⇒ Object
Returns the value of attribute homework_submission_url.
5 6 7 |
# File 'lib/skydrive/file.rb', line 5 def homework_submission_url @homework_submission_url end |
#icon ⇒ Object
Returns the value of attribute icon.
5 6 7 |
# File 'lib/skydrive/file.rb', line 5 def icon @icon end |
#is_embeddable ⇒ Object
Returns the value of attribute is_embeddable.
5 6 7 |
# File 'lib/skydrive/file.rb', line 5 def @is_embeddable end |
#is_image ⇒ Object
Returns the value of attribute is_image.
5 6 7 |
# File 'lib/skydrive/file.rb', line 5 def is_image @is_image end |
#is_text ⇒ Object
Returns the value of attribute is_text.
5 6 7 |
# File 'lib/skydrive/file.rb', line 5 def is_text @is_text end |
#is_video ⇒ Object
Returns the value of attribute is_video.
5 6 7 |
# File 'lib/skydrive/file.rb', line 5 def is_video @is_video end |
#kind ⇒ Object
Returns the value of attribute kind.
5 6 7 |
# File 'lib/skydrive/file.rb', line 5 def kind @kind end |
#mime_comment ⇒ Object
Returns the value of attribute mime_comment.
5 6 7 |
# File 'lib/skydrive/file.rb', line 5 def mime_comment @mime_comment end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/skydrive/file.rb', line 5 def name @name end |
#server_relative_url ⇒ Object
Returns the value of attribute server_relative_url.
5 6 7 |
# File 'lib/skydrive/file.rb', line 5 def server_relative_url @server_relative_url end |
#suffix ⇒ Object
Returns the value of attribute suffix.
5 6 7 |
# File 'lib/skydrive/file.rb', line 5 def suffix @suffix end |
#time_created ⇒ Object
Returns the value of attribute time_created.
5 6 7 |
# File 'lib/skydrive/file.rb', line 5 def time_created @time_created end |
#time_last_modified ⇒ Object
Returns the value of attribute time_last_modified.
5 6 7 |
# File 'lib/skydrive/file.rb', line 5 def time_last_modified @time_last_modified end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/skydrive/file.rb', line 5 def title @title end |
#uri ⇒ Object
Returns the value of attribute uri.
5 6 7 |
# File 'lib/skydrive/file.rb', line 5 def uri @uri end |
Instance Method Details
#update_content_type_data(allowed_extensions = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/skydrive/file.rb', line 9 def update_content_type_data(allowed_extensions=nil) self. = true mm = MimeMagic.by_path(self.name) if mm if mm.image? case mm.to_s when 'image/png' self.icon = "png" when 'image/jpeg' self.icon = "jpg" else self.icon = "jpg" end elsif mm.text? || mm.subtype == "msword" if mm.extensions & ['doc', 'docx'] self.icon = "word" else self.icon = "file" end elsif mm.to_s == 'application/pdf' self.icon = "pdf" else self.icon = "file" end self.kind = mm.comment self.suffix = mm.extensions.last if allowed_extensions.blank? || (allowed_extensions & mm.extensions).size > 0 self. = true else self. = false end else self.icon = "file" self.kind = '' self.suffix = self.name.split('.').try(:last) || '' self. = false end end |