Class: Sinbotra::Bot::User
- Inherits:
-
Object
- Object
- Sinbotra::Bot::User
- Defined in:
- lib/sinbotra/bot/user.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#conversations ⇒ Object
readonly
Returns the value of attribute conversations.
-
#current_message ⇒ Object
readonly
Returns the value of attribute current_message.
-
#history ⇒ Object
readonly
Returns the value of attribute history.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#session_id ⇒ Object
readonly
Returns the value of attribute session_id.
Instance Method Summary collapse
- #current_conversation ⇒ Object
-
#destroy ⇒ Object
remove user while not removing history.
- #handle_message(msg) ⇒ Object
- #in_conversation? ⇒ Boolean
-
#initialize(id, history = Sinbotra::Bot::DefaultMessageHistory.new) ⇒ User
constructor
A new instance of User.
-
#logged_in? ⇒ Boolean
Sessions.
-
#start_conversation(convo) ⇒ Object
Conversations.
Constructor Details
#initialize(id, history = Sinbotra::Bot::DefaultMessageHistory.new) ⇒ User
Returns a new instance of User.
12 13 14 15 16 17 18 |
# File 'lib/sinbotra/bot/user.rb', line 12 def initialize(id, history=Sinbotra::Bot::DefaultMessageHistory.new) @id = id @history = history @session_id = nil @conversations = [] start_session end |
Instance Attribute Details
#conversations ⇒ Object (readonly)
Returns the value of attribute conversations.
9 10 11 |
# File 'lib/sinbotra/bot/user.rb', line 9 def conversations @conversations end |
#current_message ⇒ Object (readonly)
Returns the value of attribute current_message.
8 9 10 |
# File 'lib/sinbotra/bot/user.rb', line 8 def end |
#history ⇒ Object (readonly)
Returns the value of attribute history.
10 11 12 |
# File 'lib/sinbotra/bot/user.rb', line 10 def history @history end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/sinbotra/bot/user.rb', line 6 def id @id end |
#session_id ⇒ Object (readonly)
Returns the value of attribute session_id.
7 8 9 |
# File 'lib/sinbotra/bot/user.rb', line 7 def session_id @session_id end |
Instance Method Details
#current_conversation ⇒ Object
45 46 47 |
# File 'lib/sinbotra/bot/user.rb', line 45 def current_conversation conversations.find { |c| c.active? } end |
#destroy ⇒ Object
remove user while not removing history
30 31 32 |
# File 'lib/sinbotra/bot/user.rb', line 30 def destroy end_session end |
#handle_message(msg) ⇒ Object
20 21 22 23 |
# File 'lib/sinbotra/bot/user.rb', line 20 def (msg) = msg history.(msg) end |
#in_conversation? ⇒ Boolean
41 42 43 |
# File 'lib/sinbotra/bot/user.rb', line 41 def in_conversation? !current_conversation.nil? end |
#logged_in? ⇒ Boolean
Sessions
27 |
# File 'lib/sinbotra/bot/user.rb', line 27 def logged_in?() !@session_id.nil? end |
#start_conversation(convo) ⇒ Object
Conversations
36 37 38 39 |
# File 'lib/sinbotra/bot/user.rb', line 36 def start_conversation(convo) conversations.unshift(convo) convo.start end |