Class: MAndM::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/m_and_m/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCli

Returns a new instance of Cli.



9
10
11
# File 'lib/m_and_m/cli.rb', line 9

def initialize
  @preferences = MAndM::Preferences.new '.m_and_m'
end

Instance Attribute Details

#preferencesObject (readonly)

Returns the value of attribute preferences.



7
8
9
# File 'lib/m_and_m/cli.rb', line 7

def preferences
  @preferences
end

Instance Method Details

#execute(*args) ⇒ Object



13
14
15
16
17
# File 'lib/m_and_m/cli.rb', line 13

def execute *args
  command = args.shift
  command = :list unless command
  send command, *args
end

#listObject



19
20
21
22
23
# File 'lib/m_and_m/cli.rb', line 19

def list
  server.messages.each do |message|
    puts "#{c :yellow, time(message["at"])} #{c :magenta, message["from"]} said #{c :green, message["message"]}"
  end
end

#say(who, message_id) ⇒ Object



25
26
27
# File 'lib/m_and_m/cli.rb', line 25

def say who, message_id
  server.say uuid_for(who), message_id
end