Class: Schatter::Command::ListMessages
- Inherits:
-
Object
- Object
- Schatter::Command::ListMessages
- Includes:
- Schatter::Colour, Index
- Defined in:
- lib/schatter/command/list_messages.rb
Constant Summary
Constants included from Index
Instance Attribute Summary collapse
-
#conversation ⇒ Object
readonly
Returns the value of attribute conversation.
-
#help ⇒ Object
readonly
Returns the value of attribute help.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Instance Method Summary collapse
- #description(message, index) ⇒ Object
- #execute(*ignored) ⇒ Object
-
#initialize(conversation) ⇒ ListMessages
constructor
A new instance of ListMessages.
Methods included from Index
Methods included from Schatter::Colour
Constructor Details
#initialize(conversation) ⇒ ListMessages
Returns a new instance of ListMessages.
10 11 12 13 14 |
# File 'lib/schatter/command/list_messages.rb', line 10 def initialize conversation @conversation = conversation @usage = '' @help = 'Lists messages for the current conversation' end |
Instance Attribute Details
#conversation ⇒ Object (readonly)
Returns the value of attribute conversation.
8 9 10 |
# File 'lib/schatter/command/list_messages.rb', line 8 def conversation @conversation end |
#help ⇒ Object (readonly)
Returns the value of attribute help.
8 9 10 |
# File 'lib/schatter/command/list_messages.rb', line 8 def help @help end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
8 9 10 |
# File 'lib/schatter/command/list_messages.rb', line 8 def usage @usage end |
Instance Method Details
#description(message, index) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/schatter/command/list_messages.rb', line 22 def description , index person = conversation.people[.person_id] parent_index = conversation..keys.index .parent_id email = person ? person.email : '?' list = [ c(to_index(index), :yellow), c(., :blue), c(email, :magenta), .content ] list << c("(reply to #{to_index(parent_index)})", :green) if parent_index list.join ' ' end |
#execute(*ignored) ⇒ Object
16 17 18 19 20 |
# File 'lib/schatter/command/list_messages.rb', line 16 def execute *ignored conversation.(true).values.each_with_index do |, index| puts description , index end end |