Class: Hipbot::Response

Inherits:
Struct
  • Object
show all
Includes:
Helpers
Defined in:
lib/hipbot/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*_) ⇒ Response

Returns a new instance of Response.



8
9
10
11
# File 'lib/hipbot/response.rb', line 8

def initialize *_
  super
  Hipbot.logger.info("RESPONSE WITH #{reaction}")
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (protected)



32
33
34
# File 'lib/hipbot/response.rb', line 32

def method_missing method, *args, &block
  plugin.send(method, *args, &block)
end

Instance Attribute Details

#messageObject

Returns the value of attribute message

Returns:

  • (Object)

    the current value of message



2
3
4
# File 'lib/hipbot/response.rb', line 2

def message
  @message
end

#reactionObject

Returns the value of attribute reaction

Returns:

  • (Object)

    the current value of reaction



2
3
4
# File 'lib/hipbot/response.rb', line 2

def reaction
  @reaction
end

Instance Method Details

#invoke(arguments) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/hipbot/response.rb', line 13

def invoke arguments
  handle_errors do
    instance_exec(*arguments, &reaction.block)
  end
rescue Exception => e
  instance_exec(e, &Hipbot.exception_handler)
end

#reply(message, room = self.room) ⇒ Object



21
22
23
# File 'lib/hipbot/response.rb', line 21

def reply message, room = self.room
  (room || sender).send_message(message)
end