Class: Skydrive::File

Inherits:
Object
  • Object
show all
Defined in:
lib/skydrive/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#content_tagObject

Returns the value of attribute content_tag.



5
6
7
# File 'lib/skydrive/file.rb', line 5

def 
  @content_tag
end

#content_typeObject

Returns the value of attribute content_type.



5
6
7
# File 'lib/skydrive/file.rb', line 5

def content_type
  @content_type
end

#file_sizeObject

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_urlObject

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

#iconObject

Returns the value of attribute icon.



5
6
7
# File 'lib/skydrive/file.rb', line 5

def icon
  @icon
end

#is_embeddableObject

Returns the value of attribute is_embeddable.



5
6
7
# File 'lib/skydrive/file.rb', line 5

def is_embeddable
  @is_embeddable
end

#is_imageObject

Returns the value of attribute is_image.



5
6
7
# File 'lib/skydrive/file.rb', line 5

def is_image
  @is_image
end

#is_textObject

Returns the value of attribute is_text.



5
6
7
# File 'lib/skydrive/file.rb', line 5

def is_text
  @is_text
end

#is_videoObject

Returns the value of attribute is_video.



5
6
7
# File 'lib/skydrive/file.rb', line 5

def is_video
  @is_video
end

#kindObject

Returns the value of attribute kind.



5
6
7
# File 'lib/skydrive/file.rb', line 5

def kind
  @kind
end

#mime_commentObject

Returns the value of attribute mime_comment.



5
6
7
# File 'lib/skydrive/file.rb', line 5

def mime_comment
  @mime_comment
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/skydrive/file.rb', line 5

def name
  @name
end

#server_relative_urlObject

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

#suffixObject

Returns the value of attribute suffix.



5
6
7
# File 'lib/skydrive/file.rb', line 5

def suffix
  @suffix
end

#time_createdObject

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_modifiedObject

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

#titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/skydrive/file.rb', line 5

def title
  @title
end

#uriObject

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.is_embeddable = 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.is_embeddable = true
    else
      self.is_embeddable = false
    end
  else
    self.icon = "file"
    self.kind = ''
    self.suffix = self.name.split('.').try(:last) || ''
    self.is_embeddable = false
  end
end