Class: Trello::Attachment

Inherits:
BasicData show all
Defined in:
lib/trello/attachment.rb

Overview

A file or url that is linked to a Trello card

Direct Known Subclasses

CoverImage

Instance Attribute Summary collapse

Attributes inherited from BasicData

#client

Instance Method Summary collapse

Methods inherited from BasicData

#==, client, create, find, #initialize, many, one, parse, parse_many, path_name, #refresh!, register_attributes, save

Methods included from JsonUtils

included

Constructor Details

This class inherits a constructor from Trello::BasicData

Instance Attribute Details

#bytesFixnum

Returns:

  • (Fixnum)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/trello/attachment.rb', line 20

class Attachment < BasicData
  register_attributes :name, :id, :pos, :url, :bytes, :member_id, :date, :is_upload, :mime_type, :previews
  # Update the fields of an attachment.
  #
  # Supply a hash of stringkeyed data retrieved from the Trello API representing
  # an attachment.
  def update_fields(fields)
    attributes[:name]      = fields['name'] || attributes[:name]
    attributes[:id]        = fields['id'] || attributes[:id]
    attributes[:pos]       = fields['pos'] || attributes[:pos]
    attributes[:url]       = fields['url'] || attributes[:url]
    attributes[:bytes]     = fields['bytes'].to_i || attributes[:bytes]
    attributes[:member_id] = fields['idMember'] || attributes[:member_id]
    attributes[:date]      = Time.parse(fields['date']).presence || attributes[:date]
    attributes[:is_upload] = fields['isUpload'] if fields.has_key?('isUpload')
    attributes[:mime_type] = fields['mimeType'] || attributes[:mime_type]
    attributes[:previews]  = fields['previews'] if fields.has_key?('previews')
    self
  end
end

#dateDatetime

Returns:

  • (Datetime)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/trello/attachment.rb', line 20

class Attachment < BasicData
  register_attributes :name, :id, :pos, :url, :bytes, :member_id, :date, :is_upload, :mime_type, :previews
  # Update the fields of an attachment.
  #
  # Supply a hash of stringkeyed data retrieved from the Trello API representing
  # an attachment.
  def update_fields(fields)
    attributes[:name]      = fields['name'] || attributes[:name]
    attributes[:id]        = fields['id'] || attributes[:id]
    attributes[:pos]       = fields['pos'] || attributes[:pos]
    attributes[:url]       = fields['url'] || attributes[:url]
    attributes[:bytes]     = fields['bytes'].to_i || attributes[:bytes]
    attributes[:member_id] = fields['idMember'] || attributes[:member_id]
    attributes[:date]      = Time.parse(fields['date']).presence || attributes[:date]
    attributes[:is_upload] = fields['isUpload'] if fields.has_key?('isUpload')
    attributes[:mime_type] = fields['mimeType'] || attributes[:mime_type]
    attributes[:previews]  = fields['previews'] if fields.has_key?('previews')
    self
  end
end

#idString

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/trello/attachment.rb', line 20

class Attachment < BasicData
  register_attributes :name, :id, :pos, :url, :bytes, :member_id, :date, :is_upload, :mime_type, :previews
  # Update the fields of an attachment.
  #
  # Supply a hash of stringkeyed data retrieved from the Trello API representing
  # an attachment.
  def update_fields(fields)
    attributes[:name]      = fields['name'] || attributes[:name]
    attributes[:id]        = fields['id'] || attributes[:id]
    attributes[:pos]       = fields['pos'] || attributes[:pos]
    attributes[:url]       = fields['url'] || attributes[:url]
    attributes[:bytes]     = fields['bytes'].to_i || attributes[:bytes]
    attributes[:member_id] = fields['idMember'] || attributes[:member_id]
    attributes[:date]      = Time.parse(fields['date']).presence || attributes[:date]
    attributes[:is_upload] = fields['isUpload'] if fields.has_key?('isUpload')
    attributes[:mime_type] = fields['mimeType'] || attributes[:mime_type]
    attributes[:previews]  = fields['previews'] if fields.has_key?('previews')
    self
  end
end

#is_uploadBoolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/trello/attachment.rb', line 20

class Attachment < BasicData
  register_attributes :name, :id, :pos, :url, :bytes, :member_id, :date, :is_upload, :mime_type, :previews
  # Update the fields of an attachment.
  #
  # Supply a hash of stringkeyed data retrieved from the Trello API representing
  # an attachment.
  def update_fields(fields)
    attributes[:name]      = fields['name'] || attributes[:name]
    attributes[:id]        = fields['id'] || attributes[:id]
    attributes[:pos]       = fields['pos'] || attributes[:pos]
    attributes[:url]       = fields['url'] || attributes[:url]
    attributes[:bytes]     = fields['bytes'].to_i || attributes[:bytes]
    attributes[:member_id] = fields['idMember'] || attributes[:member_id]
    attributes[:date]      = Time.parse(fields['date']).presence || attributes[:date]
    attributes[:is_upload] = fields['isUpload'] if fields.has_key?('isUpload')
    attributes[:mime_type] = fields['mimeType'] || attributes[:mime_type]
    attributes[:previews]  = fields['previews'] if fields.has_key?('previews')
    self
  end
end

#mime_typeString

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/trello/attachment.rb', line 20

class Attachment < BasicData
  register_attributes :name, :id, :pos, :url, :bytes, :member_id, :date, :is_upload, :mime_type, :previews
  # Update the fields of an attachment.
  #
  # Supply a hash of stringkeyed data retrieved from the Trello API representing
  # an attachment.
  def update_fields(fields)
    attributes[:name]      = fields['name'] || attributes[:name]
    attributes[:id]        = fields['id'] || attributes[:id]
    attributes[:pos]       = fields['pos'] || attributes[:pos]
    attributes[:url]       = fields['url'] || attributes[:url]
    attributes[:bytes]     = fields['bytes'].to_i || attributes[:bytes]
    attributes[:member_id] = fields['idMember'] || attributes[:member_id]
    attributes[:date]      = Time.parse(fields['date']).presence || attributes[:date]
    attributes[:is_upload] = fields['isUpload'] if fields.has_key?('isUpload')
    attributes[:mime_type] = fields['mimeType'] || attributes[:mime_type]
    attributes[:previews]  = fields['previews'] if fields.has_key?('previews')
    self
  end
end

#nameString

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/trello/attachment.rb', line 20

class Attachment < BasicData
  register_attributes :name, :id, :pos, :url, :bytes, :member_id, :date, :is_upload, :mime_type, :previews
  # Update the fields of an attachment.
  #
  # Supply a hash of stringkeyed data retrieved from the Trello API representing
  # an attachment.
  def update_fields(fields)
    attributes[:name]      = fields['name'] || attributes[:name]
    attributes[:id]        = fields['id'] || attributes[:id]
    attributes[:pos]       = fields['pos'] || attributes[:pos]
    attributes[:url]       = fields['url'] || attributes[:url]
    attributes[:bytes]     = fields['bytes'].to_i || attributes[:bytes]
    attributes[:member_id] = fields['idMember'] || attributes[:member_id]
    attributes[:date]      = Time.parse(fields['date']).presence || attributes[:date]
    attributes[:is_upload] = fields['isUpload'] if fields.has_key?('isUpload')
    attributes[:mime_type] = fields['mimeType'] || attributes[:mime_type]
    attributes[:previews]  = fields['previews'] if fields.has_key?('previews')
    self
  end
end

#posFloat

Returns:

  • (Float)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/trello/attachment.rb', line 20

class Attachment < BasicData
  register_attributes :name, :id, :pos, :url, :bytes, :member_id, :date, :is_upload, :mime_type, :previews
  # Update the fields of an attachment.
  #
  # Supply a hash of stringkeyed data retrieved from the Trello API representing
  # an attachment.
  def update_fields(fields)
    attributes[:name]      = fields['name'] || attributes[:name]
    attributes[:id]        = fields['id'] || attributes[:id]
    attributes[:pos]       = fields['pos'] || attributes[:pos]
    attributes[:url]       = fields['url'] || attributes[:url]
    attributes[:bytes]     = fields['bytes'].to_i || attributes[:bytes]
    attributes[:member_id] = fields['idMember'] || attributes[:member_id]
    attributes[:date]      = Time.parse(fields['date']).presence || attributes[:date]
    attributes[:is_upload] = fields['isUpload'] if fields.has_key?('isUpload')
    attributes[:mime_type] = fields['mimeType'] || attributes[:mime_type]
    attributes[:previews]  = fields['previews'] if fields.has_key?('previews')
    self
  end
end

#urlString

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/trello/attachment.rb', line 20

class Attachment < BasicData
  register_attributes :name, :id, :pos, :url, :bytes, :member_id, :date, :is_upload, :mime_type, :previews
  # Update the fields of an attachment.
  #
  # Supply a hash of stringkeyed data retrieved from the Trello API representing
  # an attachment.
  def update_fields(fields)
    attributes[:name]      = fields['name'] || attributes[:name]
    attributes[:id]        = fields['id'] || attributes[:id]
    attributes[:pos]       = fields['pos'] || attributes[:pos]
    attributes[:url]       = fields['url'] || attributes[:url]
    attributes[:bytes]     = fields['bytes'].to_i || attributes[:bytes]
    attributes[:member_id] = fields['idMember'] || attributes[:member_id]
    attributes[:date]      = Time.parse(fields['date']).presence || attributes[:date]
    attributes[:is_upload] = fields['isUpload'] if fields.has_key?('isUpload')
    attributes[:mime_type] = fields['mimeType'] || attributes[:mime_type]
    attributes[:previews]  = fields['previews'] if fields.has_key?('previews')
    self
  end
end

Instance Method Details

#update_fields(fields) ⇒ Object

Update the fields of an attachment.

Supply a hash of stringkeyed data retrieved from the Trello API representing an attachment.



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/trello/attachment.rb', line 26

def update_fields(fields)
  attributes[:name]      = fields['name'] || attributes[:name]
  attributes[:id]        = fields['id'] || attributes[:id]
  attributes[:pos]       = fields['pos'] || attributes[:pos]
  attributes[:url]       = fields['url'] || attributes[:url]
  attributes[:bytes]     = fields['bytes'].to_i || attributes[:bytes]
  attributes[:member_id] = fields['idMember'] || attributes[:member_id]
  attributes[:date]      = Time.parse(fields['date']).presence || attributes[:date]
  attributes[:is_upload] = fields['isUpload'] if fields.has_key?('isUpload')
  attributes[:mime_type] = fields['mimeType'] || attributes[:mime_type]
  attributes[:previews]  = fields['previews'] if fields.has_key?('previews')
  self
end