Class: ChatMesage
- Inherits:
-
Object
- Object
- ChatMesage
- Defined in:
- lib/models/chat_message.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#target_id ⇒ Object
readonly
Returns the value of attribute target_id.
Instance Method Summary collapse
-
#initialize(data = {}) ⇒ ChatMesage
constructor
A new instance of ChatMesage.
- #to_s ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ ChatMesage
Returns a new instance of ChatMesage.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/models/chat_message.rb', line 6 def initialize(data = {}) # @mode # Type: Integer @mode = data[:mode] # @client_id # Type: Integer @client_id = data[:client_id] # @target_id # Type: Integer @target_id = data[:target_id] # @message # Type: String @message = data[:message] # @author # Type: Player see player.rb @author = data[:author] end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
4 5 6 |
# File 'lib/models/chat_message.rb', line 4 def @author end |
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
4 5 6 |
# File 'lib/models/chat_message.rb', line 4 def client_id @client_id end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
4 5 6 |
# File 'lib/models/chat_message.rb', line 4 def @message end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
4 5 6 |
# File 'lib/models/chat_message.rb', line 4 def mode @mode end |
#target_id ⇒ Object (readonly)
Returns the value of attribute target_id.
4 5 6 |
# File 'lib/models/chat_message.rb', line 4 def target_id @target_id end |
Instance Method Details
#to_s ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/models/chat_message.rb', line 28 def to_s # server message return "*** #{@message}" if @client_id == -1 # player message # should never be from an invalid id # but lets not crash if servers send weird stuff name = '' name = @author.name if @author "#{name}: #{@message}" end |