Class: Jabbot::Bot::Message

Inherits:
Struct
  • Object
show all
Defined in:
lib/jabbot/bot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#textObject

Returns the value of attribute text

Returns:

  • (Object)

    the current value of text



16
17
18
# File 'lib/jabbot/bot.rb', line 16

def text
  @text
end

#timeObject

Returns the value of attribute time

Returns:

  • (Object)

    the current value of time



16
17
18
# File 'lib/jabbot/bot.rb', line 16

def time
  @time
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



16
17
18
# File 'lib/jabbot/bot.rb', line 16

def type
  @type
end

#userObject

Returns the value of attribute user

Returns:

  • (Object)

    the current value of user



16
17
18
# File 'lib/jabbot/bot.rb', line 16

def user
  @user
end

Instance Method Details

#to_json(*a) ⇒ Object

Encode a message in JSON A message is just a hash of its values



23
24
25
26
27
28
29
30
# File 'lib/jabbot/bot.rb', line 23

def to_json(*a)
  {
    :user => user,
    :text => text,
    :time => time,
    :type => type
  }.to_json(*a)
end

#to_sObject



17
18
19
# File 'lib/jabbot/bot.rb', line 17

def to_s
  "#{user}: #{text}"
end