Class: Taleo::Attachment

Inherits:
Resource show all
Defined in:
lib/taleo/attachment.rb

Instance Attribute Summary

Attributes inherited from Resource

#client, #data

Instance Method Summary collapse

Methods inherited from Resource

has_many, has_one, #initialize, #related_resource, #related_resources, #relationship_urls

Constructor Details

This class inherits a constructor from Taleo::Resource

Instance Method Details

#can_download?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/taleo/attachment.rb', line 19

def can_download?
  data.key?('downloadUrl')
end

#content_typeObject



15
16
17
# File 'lib/taleo/attachment.rb', line 15

def content_type
  data.fetch('contentType')
end

#downloadObject



23
24
25
26
27
28
29
# File 'lib/taleo/attachment.rb', line 23

def download
  unless can_download?
    raise Error.new("Attachment #{id} is not available for download")
  end

  client.download(data.fetch('downloadUrl'))
end

#idObject



7
8
9
# File 'lib/taleo/attachment.rb', line 7

def id
  data.fetch('id')
end

#typeObject



11
12
13
# File 'lib/taleo/attachment.rb', line 11

def type
  data.fetch('attachmentType')
end