Class: WitBot::Bot::Conversation::Participant

Inherits:
Object
  • Object
show all
Defined in:
lib/wit_bot/bot/conversation/participant.rb

Direct Known Subclasses

Base

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conversation) ⇒ Participant

Returns a new instance of Participant.



7
8
9
10
# File 'lib/wit_bot/bot/conversation/participant.rb', line 7

def initialize(conversation)
  @conversation = conversation
  @conversation.add_observer self
end

Instance Attribute Details

#conversationObject (readonly)

Returns the value of attribute conversation.



5
6
7
# File 'lib/wit_bot/bot/conversation/participant.rb', line 5

def conversation
  @conversation
end

Instance Method Details

#bot?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/wit_bot/bot/conversation/participant.rb', line 12

def bot?
  true
end

#send_message(text, meta = nil) ⇒ Object Also known as: output



16
17
18
# File 'lib/wit_bot/bot/conversation/participant.rb', line 16

def send_message(text, meta=nil)
  @conversation.send_message text, self, meta
end

#update(type, message) ⇒ Object



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

def update(type, message)
  case type
    when :input
      self.on_input message if self.respond_to? :on_input, true
    when :output
      self.on_output message if self.respond_to? :on_output, true
  end
end