Class: CodenjoyRubyClient

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

Constant Summary collapse

EMPTY =

Cell status

' '
BUSY =
'*'
ROTATE_0 =

Rotate clockwise

0
ROTATE_90 =
1
ROTATE_180 =
2
ROTATE_270 =
3

Class Method Summary collapse

Class Method Details

.run(host = '0.0.0.0', port = 8888, &answer) ⇒ Object



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

def self.run(host='0.0.0.0', port=8888, &answer)
  codenjoy_server = lambda do |env|
    decoded_query = URI.decode_www_form env['QUERY_STRING']
    query = Hash[decoded_query]

    [200, {"Content-Type" => "text/plain"}, [answer.call(query)]]
  end

  Rack::Handler::WEBrick.run codenjoy_server, Host: host, Port: port
end