Class: Messages::MessageAttachment

Inherits:
Object
  • Object
show all
Defined in:
lib/yellowant/message/message_attachment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMessageAttachment

Returns a new instance of MessageAttachment.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/yellowant/message/message_attachment.rb', line 9

def initialize
  @image_url = ''
  @thumb_url = ''
  @color = ''
  @text = ''
  @author_name = ''
  @author_link = ''
  @author_icon = ''
  @footer = ''
  @footer_icon = ''
  @pretext = ''
  @title = ''
  @title_link = ''
  @status = 0
  @ts = 0
  @fields = Array.new
  @buttons = Array.new
end

Instance Attribute Details

#author_iconObject

Returns the value of attribute author_icon.



7
8
9
# File 'lib/yellowant/message/message_attachment.rb', line 7

def author_icon
  @author_icon
end

Returns the value of attribute author_link.



7
8
9
# File 'lib/yellowant/message/message_attachment.rb', line 7

def author_link
  @author_link
end

#author_nameObject

Returns the value of attribute author_name.



7
8
9
# File 'lib/yellowant/message/message_attachment.rb', line 7

def author_name
  @author_name
end

#colorObject

Returns the value of attribute color.



7
8
9
# File 'lib/yellowant/message/message_attachment.rb', line 7

def color
  @color
end

Returns the value of attribute footer.



7
8
9
# File 'lib/yellowant/message/message_attachment.rb', line 7

def footer
  @footer
end

Returns the value of attribute footer_icon.



7
8
9
# File 'lib/yellowant/message/message_attachment.rb', line 7

def footer_icon
  @footer_icon
end

#image_urlObject

Returns the value of attribute image_url.



7
8
9
# File 'lib/yellowant/message/message_attachment.rb', line 7

def image_url
  @image_url
end

#pretextObject

Returns the value of attribute pretext.



7
8
9
# File 'lib/yellowant/message/message_attachment.rb', line 7

def pretext
  @pretext
end

#statusObject

Returns the value of attribute status.



7
8
9
# File 'lib/yellowant/message/message_attachment.rb', line 7

def status
  @status
end

#textObject

Returns the value of attribute text.



7
8
9
# File 'lib/yellowant/message/message_attachment.rb', line 7

def text
  @text
end

#thumb_urlObject

Returns the value of attribute thumb_url.



7
8
9
# File 'lib/yellowant/message/message_attachment.rb', line 7

def thumb_url
  @thumb_url
end

#titleObject

Returns the value of attribute title.



7
8
9
# File 'lib/yellowant/message/message_attachment.rb', line 7

def title
  @title
end

Returns the value of attribute title_link.



7
8
9
# File 'lib/yellowant/message/message_attachment.rb', line 7

def title_link
  @title_link
end

#tsObject

Returns the value of attribute ts.



7
8
9
# File 'lib/yellowant/message/message_attachment.rb', line 7

def ts
  @ts
end

Instance Method Details

#attach_button(button) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/yellowant/message/message_attachment.rb', line 36

def attach_button(button)
  if !field.is_a? ButtonClass
    raise YellowantExceptions::YellowAntError, "Attachment must be 'AttachmentClass' class" 
  else
    @button << button.get_dict
  end
end

#attach_field(field) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/yellowant/message/message_attachment.rb', line 28

def attach_field(field)
  if !field.is_a? AttachmentClass
    raise YellowantExceptions::YellowAntError, "Attachment must be 'AttachmentClass' class" 
  else
    @field << field.get_dict
  end
end

#get_dictObject



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/yellowant/message/message_attachment.rb', line 44

def get_dict
  if !@status.is_a? Integer
    raise YellowantExceptions::YellowAntError, ":status must be an integer"
  elsif !@ts.is_a? Integer 
    raise YellowantExceptions::YellowAntError, ":ts must be an integer"
  end
  {"image_url"=> @image_url, "thumb_url"=> @thumb_url, "color"=> @color, "text"=> @text, "author_name"=> @author_name, 
  "author_icon"=> @author_icon, "author_link"=> @author_link, "ts"=> @ts, "footer"=> @footer, "footer_icon"=> @footer_icon, 
  "pretext"=> @pretext, "title"=> @title, "title_link"=> @title_link, "status"=> @status, "fields"=> @fields,
  "buttons"=> @buttons}
end