Class: Messages::MessageClass

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMessageClass

Returns a new instance of MessageClass.



8
9
10
11
12
13
14
# File 'lib/yellowant/message/message_class.rb', line 8

def initialize
  @message_text = ''
  @attachments = []
  @data = {}
  @error = {}
  @logs = {}
end

Instance Attribute Details

#attachmentsObject

Returns the value of attribute attachments.



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

def attachments
  @attachments
end

#dataObject

Returns the value of attribute data.



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

def data
  @data
end

#errorObject

Returns the value of attribute error.



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

def error
  @error
end

#logsObject

Returns the value of attribute logs.



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

def logs
  @logs
end

#message_textObject

Returns the value of attribute message_text.



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

def message_text
  @message_text
end

Instance Method Details

#attach(attachment) ⇒ Object



16
17
18
19
20
21
# File 'lib/yellowant/message/message_class.rb', line 16

def attach(attachment)
  if !attachment.is_a? MessageAttachment 
    raise YellowantExceptions::YellowAntError, "Attachment must be MessageAttachment class"
  end
  @attachments << attachment.get_dict
end

#get_dictObject



28
29
30
# File 'lib/yellowant/message/message_class.rb', line 28

def get_dict
  {"message_text" => @message_text, "data"=> @data, "error" => @error, "attachments"=> @attachments, "logs"=> @logs}
end

#to_jsonObject



23
24
25
26
# File 'lib/yellowant/message/message_class.rb', line 23

def to_json
  m = {"message_text" => @message_text, "data"=> @data, "error" => @error, "attachments"=> @attachments, "logs"=> @logs}
  JSON.generate(m)
end