Class: Lokii::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/lokii/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#handlersObject

Returns the value of attribute handlers.



3
4
5
# File 'lib/lokii/server.rb', line 3

def handlers
  @handlers
end

#readyObject

Returns the value of attribute ready.



3
4
5
# File 'lib/lokii/server.rb', line 3

def ready
  @ready
end

#stoppedObject

Returns the value of attribute stopped.



3
4
5
# File 'lib/lokii/server.rb', line 3

def stopped
  @stopped
end

Instance Method Details

#checkObject



51
52
53
# File 'lib/lokii/server.rb', line 51

def check
  Lokii::Logger.debug "Checking for incoming messages" if Lokii::Config.verbose
end

#complete(message) ⇒ Object



47
48
49
# File 'lib/lokii/server.rb', line 47

def complete(message)
  Lokii::Logger.debug "Message processing complete" if Lokii::Config.verbose
end

#connectObject



35
36
37
# File 'lib/lokii/server.rb', line 35

def connect
  Lokii::Logger.debug "Connecting"
end

#daemon?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/lokii/server.rb', line 31

def daemon?
  defined?(LOKII_DAEMON) && LOKII_DAEMON
end

#disconnectObject



39
40
41
# File 'lib/lokii/server.rb', line 39

def disconnect
  Lokii::Logger.debug "Disconnecting"
end

#processObject



19
20
21
22
23
24
25
# File 'lib/lokii/server.rb', line 19

def process
  # Make sure it is not stopped and that we started it
  return if stopped?     
  return unless running?
  setup unless ready?
  check
end

#ready?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/lokii/server.rb', line 5

def ready?
  defined?(@ready) && @ready
end

#running?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/lokii/server.rb', line 27

def running?
  File.exist?(File.join(Lokii::Config.root, Lokii::Config.pid).gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR))
end

#say(text, number, reply = nil) ⇒ Object



43
44
45
# File 'lib/lokii/server.rb', line 43

def say(text, number, reply = nil)
  Lokii::Logger.debug "Sending message to #{number}" 
end

#setupObject



13
14
15
16
17
# File 'lib/lokii/server.rb', line 13

def setup
  self.ready = true
  Lokii::Logger.debug "Initializing"
  Lokii::Logger.debug "Waiting for text messages"
end

#stopped?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/lokii/server.rb', line 9

def stopped?
  defined?(@stopped) && @stopped
end