Class: Message
- Inherits:
-
Object
- Object
- Message
- Defined in:
- lib/models/message.rb
Instance Attribute Summary collapse
-
#attachments ⇒ Object
Returns the value of attribute attachments.
-
#from ⇒ Object
Returns the value of attribute from.
-
#html ⇒ Object
Returns the value of attribute html.
-
#id ⇒ Object
Returns the value of attribute id.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#text ⇒ Object
Returns the value of attribute text.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
-
#initialize(json) ⇒ Message
constructor
A new instance of Message.
- #to_s ⇒ Object
Constructor Details
#initialize(json) ⇒ Message
Returns a new instance of Message.
6 7 8 9 |
# File 'lib/models/message.rb', line 6 def initialize(json) json.each { |key, value| instance_variable_set("@#{key}", value) } @attachments = @attachments&.map { || Attachment.new() } end |
Instance Attribute Details
#attachments ⇒ Object
Returns the value of attribute attachments.
4 5 6 |
# File 'lib/models/message.rb', line 4 def @attachments end |
#from ⇒ Object
Returns the value of attribute from.
4 5 6 |
# File 'lib/models/message.rb', line 4 def from @from end |
#html ⇒ Object
Returns the value of attribute html.
4 5 6 |
# File 'lib/models/message.rb', line 4 def html @html end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/models/message.rb', line 4 def id @id end |
#subject ⇒ Object
Returns the value of attribute subject.
4 5 6 |
# File 'lib/models/message.rb', line 4 def subject @subject end |
#text ⇒ Object
Returns the value of attribute text.
4 5 6 |
# File 'lib/models/message.rb', line 4 def text @text end |
#to ⇒ Object
Returns the value of attribute to.
4 5 6 |
# File 'lib/models/message.rb', line 4 def to @to end |
Instance Method Details
#to_s ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/models/message.rb', line 11 def to_s <<~MESSAGE ID: #{@id} From: #{@from} To: #{@to} Subject: #{@subject} Text: #{@text} HTML: #{@html} Attachments: #{@attachments.map(&:to_s).join("\n")} MESSAGE end |