Class: Rebot::Message
- Inherits:
-
Object
- Object
- Rebot::Message
- Defined in:
- lib/rebot/message.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(data, bot) ⇒ Message
constructor
A new instance of Message.
Constructor Details
#initialize(data, bot) ⇒ Message
Returns a new instance of Message.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/rebot/message.rb', line 5 def initialize(data, bot) @bot = bot @data = data # FIXME: calling private method @mention_regex = /\A(<@#{@bot.send(:user_id)}>)[\s\:](.*)/ @event = resolve_event(data['type']) @text = cleanup_text(data['text']) @user = data['user'] @channel = data['channel'] end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
3 4 5 |
# File 'lib/rebot/message.rb', line 3 def channel @channel end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
3 4 5 |
# File 'lib/rebot/message.rb', line 3 def event @event end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
3 4 5 |
# File 'lib/rebot/message.rb', line 3 def text @text end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
3 4 5 |
# File 'lib/rebot/message.rb', line 3 def user @user end |
Instance Method Details
#[](key) ⇒ Object
22 23 24 |
# File 'lib/rebot/message.rb', line 22 def [](key) @data[key.to_s] end |
#[]=(key, value) ⇒ Object
18 19 20 |
# File 'lib/rebot/message.rb', line 18 def []=(key, value) @data[key.to_s] = value end |