Class: Settlers::Application::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/settlers/application.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeServer

Returns a new instance of Server.



79
80
81
82
83
84
85
86
87
88
# File 'lib/settlers/application.rb', line 79

def initialize
  @name = "#{`hostname -s`.chomp}-#{`whoami`.chomp}"
  @host = 'localhost'
  @port = 8880
  @startup_delay = 4
  @maximum_connections = 12
  @username = 'root'
  @password = ''
  @robot_names = %w(Leonardo Humperdink Elwood)
end

Instance Attribute Details

#hostObject (readonly)

Maybe we can change these to attr_writer as we’d like to make them command-line configurable.



77
78
79
# File 'lib/settlers/application.rb', line 77

def host
  @host
end

#maximum_connectionsObject (readonly)

Maybe we can change these to attr_writer as we’d like to make them command-line configurable.



77
78
79
# File 'lib/settlers/application.rb', line 77

def maximum_connections
  @maximum_connections
end

#nameObject (readonly)

Maybe we can change these to attr_writer as we’d like to make them command-line configurable.



77
78
79
# File 'lib/settlers/application.rb', line 77

def name
  @name
end

#passwordObject (readonly)

Maybe we can change these to attr_writer as we’d like to make them command-line configurable.



77
78
79
# File 'lib/settlers/application.rb', line 77

def password
  @password
end

#portObject (readonly)

Maybe we can change these to attr_writer as we’d like to make them command-line configurable.



77
78
79
# File 'lib/settlers/application.rb', line 77

def port
  @port
end

#robot_namesObject (readonly)

Maybe we can change these to attr_writer as we’d like to make them command-line configurable.



77
78
79
# File 'lib/settlers/application.rb', line 77

def robot_names
  @robot_names
end

#startup_delayObject (readonly)

Maybe we can change these to attr_writer as we’d like to make them command-line configurable.



77
78
79
# File 'lib/settlers/application.rb', line 77

def startup_delay
  @startup_delay
end

#usernameObject (readonly)

Maybe we can change these to attr_writer as we’d like to make them command-line configurable.



77
78
79
# File 'lib/settlers/application.rb', line 77

def username
  @username
end

Instance Method Details

#startObject



90
91
92
93
94
95
# File 'lib/settlers/application.rb', line 90

def start
  announce
  serve
  sleep(startup_delay)
  start_robots
end