Class: Schatter::Command::JoinConversation

Inherits:
Object
  • Object
show all
Includes:
Index
Defined in:
lib/schatter/command/join_conversation.rb

Constant Summary

Constants included from Index

Index::LETTERS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Index

#from_index, #to_index

Constructor Details

#initialize(session) ⇒ JoinConversation

Returns a new instance of JoinConversation.



9
10
11
12
13
# File 'lib/schatter/command/join_conversation.rb', line 9

def initialize session
  @session = session
  @usage = '<index>'
  @help = 'Joins a specified conversation'
end

Instance Attribute Details

#helpObject (readonly)

Returns the value of attribute help.



7
8
9
# File 'lib/schatter/command/join_conversation.rb', line 7

def help
  @help
end

#sessionObject (readonly)

Returns the value of attribute session.



7
8
9
# File 'lib/schatter/command/join_conversation.rb', line 7

def session
  @session
end

#usageObject (readonly)

Returns the value of attribute usage.



7
8
9
# File 'lib/schatter/command/join_conversation.rb', line 7

def usage
  @usage
end

Instance Method Details

#execute(index) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/schatter/command/join_conversation.rb', line 15

def execute index
  conversation = session.conversations.values[from_index(index)]
  unless conversation
    puts "invalid index"
    return
  end
  Schatter::ConversationContext.new(conversation).push
end