Class: Mchat::Message
- Inherits:
-
Object
- Object
- Mchat::Message
- Defined in:
- lib/mchat/comps/message.rb
Instance Method Summary collapse
- #display ⇒ Object
-
#initialize(message, format = :std) ⇒ Message
constructor
A new instance of Message.
Constructor Details
#initialize(message, format = :std) ⇒ Message
Returns a new instance of Message.
3 4 5 6 |
# File 'lib/mchat/comps/message.rb', line 3 def initialize(, format = :std) @message = @format = format end |
Instance Method Details
#display ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/mchat/comps/message.rb', line 8 def display if @format == :std # Time format https://devdocs.io/ruby~3/datetime#method-i-strftime tstring = Time.at(@message['timestamp'].to_i).strftime("%H:%M:%S") username = @message['user_name'] content = @message['content'] "[#{tstring.style.sea}] #{username.style.jade}: #{content.strip}\n" end end |