Class: Dropio::Asset

Inherits:
Resource show all
Defined in:
lib/dropio/asset.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Dropio::Resource

Instance Attribute Details

#artistObject

Returns the value of attribute artist.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def artist
  @artist
end

#contentsObject

Returns the value of attribute contents.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def contents
  @contents
end

#convertedObject

Returns the value of attribute converted.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def converted
  @converted
end

#created_atObject

Returns the value of attribute created_at.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def created_at
  @created_at
end

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def description
  @description
end

#dropObject

Returns the value of attribute drop.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def drop
  @drop
end

#durationObject

Returns the value of attribute duration.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def duration
  @duration
end

#fileObject

Returns the value of attribute file.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def file
  @file
end

#filesizeObject

Returns the value of attribute filesize.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def filesize
  @filesize
end

#heightObject

Returns the value of attribute height.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def height
  @height
end

#hidden_urlObject

Returns the value of attribute hidden_url.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def hidden_url
  @hidden_url
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def name
  @name
end

#pagesObject

Returns the value of attribute pages.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def pages
  @pages
end

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def status
  @status
end

#thumbnailObject

Returns the value of attribute thumbnail.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def thumbnail
  @thumbnail
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def title
  @title
end

#track_titleObject

Returns the value of attribute track_title.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def track_title
  @track_title
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def type
  @type
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def url
  @url
end

#widthObject

Returns the value of attribute width.



3
4
5
# File 'lib/dropio/asset.rb', line 3

def width
  @width
end

Instance Method Details

#commentsObject

Returns the comments on this asset. Comments are loaded lazily. The first call to comments will fetch the comments from the server. They are then cached until the asset is reloaded.



10
11
12
13
# File 'lib/dropio/asset.rb', line 10

def comments
  @comments = Dropio::Client.instance.find_comments(self) if @comments.nil?
  @comments ||= []
end

#create_comment(contents) ⇒ Object

Adds a comment to the asset with the given contents. Returns the new Comment.



17
18
19
# File 'lib/dropio/asset.rb', line 17

def create_comment(contents)
  Dropio::Client.instance.create_comment(self, contents)
end

#destroy!Object

Destroys the asset on drop.io. Don’t try to use an Asset after destroying it.



27
28
29
30
# File 'lib/dropio/asset.rb', line 27

def destroy!
  Dropio::Client.instance.destroy_asset(self)
  nil
end

#faxable?Boolean

Returns true if the Asset can be faxed.

Returns:

  • (Boolean)


33
34
35
# File 'lib/dropio/asset.rb', line 33

def faxable?
  return type.downcase == "document"
end

#generate_urlObject

Generates an authenticated URL that will bypass any login action.



56
57
58
# File 'lib/dropio/asset.rb', line 56

def generate_url
  Dropio::Client.instance.generate_asset_url(self)
end

#saveObject

Saves the asset back to drop.io.



22
23
24
# File 'lib/dropio/asset.rb', line 22

def save
  Dropio::Client.instance.save_asset(self)
end

#send_to_drop(drop_name) ⇒ Object

Sends the asset to a Drop by drop_name



51
52
53
# File 'lib/dropio/asset.rb', line 51

def send_to_drop(drop_name)
  Dropio::Client.instance.send_to_drop(self, drop_name)
end

#send_to_emails(emails = [], message = nil) ⇒ Object

Sends the asset to the given emails with an optional message.



46
47
48
# File 'lib/dropio/asset.rb', line 46

def send_to_emails(emails = [], message = nil)
  Dropio::Client.instance.send_to_emails(self, emails, message)
end

#send_to_fax(fax_number) ⇒ Object

Fax the asset to the given fax_number. Make sure the Asset is faxable? first, or send_to_fax will raise an error.



39
40
41
42
43
# File 'lib/dropio/asset.rb', line 39

def send_to_fax(fax_number)
  raise "Can't fax Asset: #{self.inspect} is not faxable" unless faxable?
  Dropio::Client.instance.send_to_fax(self, fax_number)
  nil
end