Class: Daneel::Adapters::Shell

Inherits:
Daneel::Adapter show all
Defined in:
lib/daneel/adapters/shell.rb

Instance Attribute Summary

Attributes inherited from Plugin

#robot

Instance Method Summary collapse

Methods inherited from Daneel::Adapter

#me, named

Methods inherited from Plugin

#logger, requires_env

Constructor Details

#initialize(robot) ⇒ Shell

Returns a new instance of Shell.



8
9
10
11
12
# File 'lib/daneel/adapters/shell.rb', line 8

def initialize(robot)
  super
  @room = Room.new("shell", self)
  @user = User.new(1, ENV['USER'])
end

Instance Method Details

#announce(*strings) ⇒ Object



29
30
31
32
# File 'lib/daneel/adapters/shell.rb', line 29

def announce(*strings)
  puts
  say @room.id, *strings
end

#runObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/daneel/adapters/shell.rb', line 14

def run
  # End the line we were on when we exit
  trap(:EXIT){ print "\n" }

  while text = Readline.readline("> ", true)
    next if text.empty?
    message = Message.new(text, Time.now, "text")
    robot.receive @room, message, @user
  end
end

#say(id, *strings) ⇒ Object



25
26
27
# File 'lib/daneel/adapters/shell.rb', line 25

def say(id, *strings)
  puts *strings
end