Class: MessageQuickly::Messaging::ImageAttachment

Inherits:
Attachment show all
Defined in:
lib/message_quickly/messaging/image_attachment.rb

Instance Attribute Summary collapse

Attributes inherited from Attachment

#payload, #type

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ ImageAttachment

Returns a new instance of ImageAttachment.



7
8
9
10
# File 'lib/message_quickly/messaging/image_attachment.rb', line 7

def initialize(params = {})
  params['type'] ||= 'image'
  super(params)
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



5
6
7
# File 'lib/message_quickly/messaging/image_attachment.rb', line 5

def file
  @file
end

#file_typeObject

Returns the value of attribute file_type.



5
6
7
# File 'lib/message_quickly/messaging/image_attachment.rb', line 5

def file_type
  @file_type
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/message_quickly/messaging/image_attachment.rb', line 5

def url
  @url
end

Instance Method Details

#file?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/message_quickly/messaging/image_attachment.rb', line 12

def file?
  file.present? && file_type.present?
end

#to_hashObject



16
17
18
19
20
21
22
# File 'lib/message_quickly/messaging/image_attachment.rb', line 16

def to_hash
  if file?
    { type: type, payload: { url: '' } } # cannot send empty hash
  else
    { type: type, payload: { url: url } }
  end
end