Class: Schatter::Command::ListConversations

Inherits:
Object
  • Object
show all
Includes:
Schatter::Colour, Index
Defined in:
lib/schatter/command/list_conversations.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

Methods included from Schatter::Colour

#c

Constructor Details

#initialize(session) ⇒ ListConversations

Returns a new instance of ListConversations.



10
11
12
13
14
# File 'lib/schatter/command/list_conversations.rb', line 10

def initialize session
  @session = session
  @usage = ''
  @help = 'Lists current conversations'
end

Instance Attribute Details

#helpObject (readonly)

Returns the value of attribute help.



8
9
10
# File 'lib/schatter/command/list_conversations.rb', line 8

def help
  @help
end

#sessionObject (readonly)

Returns the value of attribute session.



8
9
10
# File 'lib/schatter/command/list_conversations.rb', line 8

def session
  @session
end

#usageObject (readonly)

Returns the value of attribute usage.



8
9
10
# File 'lib/schatter/command/list_conversations.rb', line 8

def usage
  @usage
end

Instance Method Details

#description(conversation, index) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/schatter/command/list_conversations.rb', line 22

def description conversation, index
  [
    c(to_index(index), :yellow),
    c(conversation.formatted_timestamp, :blue),
    c(conversation.name, :magenta),
  ].join ' '
end

#execute(ignored) ⇒ Object



16
17
18
19
20
# File 'lib/schatter/command/list_conversations.rb', line 16

def execute ignored
  session.conversations(true).values.each_with_index do |conversation, index|
    puts description conversation, index
  end
end