Class: MeshChat::Message::Whisper

Inherits:
Base
  • Object
show all
Defined in:
lib/meshchat/message/whisper.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#message, #payload, #sender_location, #sender_name, #sender_uid, #time_recieved

Instance Method Summary collapse

Methods inherited from Base

#client, #client_version, #handle, #render, #respond, #type

Constructor Details

#initialize(message: nil, sender_name: nil, sender_location: nil, sender_uid: nil, time_recieved: nil, payload: nil, to: '') ⇒ Whisper



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/meshchat/message/whisper.rb', line 6

def initialize(
  message: nil,
  sender_name: nil,
  sender_location: nil,
  sender_uid: nil,
  time_recieved: nil,
  payload: nil,
  to: '')

  super(
    message: message,
    sender_name: sender_name,
    sender_location: sender_location,
    sender_uid: sender_uid,
    time_recieved: time_recieved,
    payload: payload)

  self._to = to
end

Instance Attribute Details

#_toObject

Returns the value of attribute _to.



4
5
6
# File 'lib/meshchat/message/whisper.rb', line 4

def _to
  @_to
end

Instance Method Details

#displayObject



26
27
28
29
30
31
32
33
# File 'lib/meshchat/message/whisper.rb', line 26

def display
  time_sent = payload['time_sent'].to_s
  time = Date.parse(time_sent)
  time_recieved = time.strftime('%e/%m/%y %H:%I:%M')

  to = _to.present? ? "->#{_to}" : ''
  "#{time_recieved} #{sender_name}#{to} > #{message}"
end