Class: RedboothRuby::File

Inherits:
Base
  • Object
show all
Includes:
Operations::Create, Operations::Delete, Operations::Index, Operations::Show, Operations::Update
Defined in:
lib/redbooth-ruby/file.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#created_time, #session

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Operations::Delete

included

Methods included from Operations::Show

included

Methods included from Operations::Update

included

Methods included from Operations::Create

included

Methods included from Operations::Index

included

Methods inherited from Base

#errors, #initialize, #parse_timestamps, #set_attributes, #valid?

Methods included from Operations::Base

included

Constructor Details

This class inherits a constructor from RedboothRuby::Base

Instance Attribute Details

#backendObject

Returns the value of attribute backend.



9
10
11
# File 'lib/redbooth-ruby/file.rb', line 9

def backend
  @backend
end

#backend_idObject

Returns the value of attribute backend_id.



9
10
11
# File 'lib/redbooth-ruby/file.rb', line 9

def backend_id
  @backend_id
end

#created_atObject

Returns the value of attribute created_at.



9
10
11
# File 'lib/redbooth-ruby/file.rb', line 9

def created_at
  @created_at
end

#idObject

Returns the value of attribute id.



9
10
11
# File 'lib/redbooth-ruby/file.rb', line 9

def id
  @id
end

#is_dirObject

Returns the value of attribute is_dir.



9
10
11
# File 'lib/redbooth-ruby/file.rb', line 9

def is_dir
  @is_dir
end

#is_downloadableObject

Returns the value of attribute is_downloadable.



9
10
11
# File 'lib/redbooth-ruby/file.rb', line 9

def is_downloadable
  @is_downloadable
end

#is_previewableObject

Returns the value of attribute is_previewable.



9
10
11
# File 'lib/redbooth-ruby/file.rb', line 9

def is_previewable
  @is_previewable
end

#is_privateObject

Returns the value of attribute is_private.



9
10
11
# File 'lib/redbooth-ruby/file.rb', line 9

def is_private
  @is_private
end

#mime_typeObject

Returns the value of attribute mime_type.



9
10
11
# File 'lib/redbooth-ruby/file.rb', line 9

def mime_type
  @mime_type
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/redbooth-ruby/file.rb', line 9

def name
  @name
end

#parent_idObject

Returns the value of attribute parent_id.



9
10
11
# File 'lib/redbooth-ruby/file.rb', line 9

def parent_id
  @parent_id
end

#pinnedObject

Returns the value of attribute pinned.



9
10
11
# File 'lib/redbooth-ruby/file.rb', line 9

def pinned
  @pinned
end

#project_idObject

Returns the value of attribute project_id.



9
10
11
# File 'lib/redbooth-ruby/file.rb', line 9

def project_id
  @project_id
end

#public_tokenObject

Returns the value of attribute public_token.



9
10
11
# File 'lib/redbooth-ruby/file.rb', line 9

def public_token
  @public_token
end

#sizeObject

Returns the value of attribute size.



9
10
11
# File 'lib/redbooth-ruby/file.rb', line 9

def size
  @size
end

#updated_atObject

Returns the value of attribute updated_at.



9
10
11
# File 'lib/redbooth-ruby/file.rb', line 9

def updated_at
  @updated_at
end

#user_idObject

Returns the value of attribute user_id.



9
10
11
# File 'lib/redbooth-ruby/file.rb', line 9

def user_id
  @user_id
end

Class Method Details

.create(attrs) ⇒ Object

Create operation overwrite to parse file first



41
42
43
# File 'lib/redbooth-ruby/file.rb', line 41

def create(attrs)
  super(parse_file(attrs))
end

Instance Method Details

#download(style = 'original', path = nil) ⇒ String

Returns a blop with the file data

Parameters:

  • style (String) (defaults to: 'original')

    The style to use

  • path (String) (defaults to: nil)

    The path to save the file to

Returns:

  • (String)

    the object metadata



32
33
34
35
36
37
# File 'lib/redbooth-ruby/file.rb', line 32

def download(style='original', path=nil)
  options = { session: session }
  options[:download_path] = path unless path.nil?
  request = RedboothRuby.request(:download, nil, "files/#{id}/download/#{style}/#{name}", {}, options)
  request.body
end