Module: Minep

Defined in:
lib/minep-request/minep.rb,
lib/minep-request/version.rb,
lib/minep-request/requests.rb

Defined Under Namespace

Modules: Request

Class Method Summary collapse

Class Method Details

.makeMsg(request, args, buflist = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/minep-request/minep.rb', line 7

def self.makeMsg request, args, buflist = nil
  args.each_key do |k|
    if k == :args
      printf "#{k} as a space-separated list : "
      input = read
      args[k] = input.split
    elsif k == :direction
      printf "#{k} (up, right, down, left, origin, end) : "
      args[k] = read
    elsif k == :number
      printf "#{k} : "
      args[k] = read.to_i
    else
      printf "#{k} : "
      args[k] = read
    end
  end
  if request == "INSERT"
    args[:text] = Base64.encode64 args[:text]
  end
  if buflist and args[:buffer]
    bufferName = args[:buffer]
    args[:buffer] = buflist[bufferName]
    return $stderr.puts "Error : This buffer doesn't exists" if args[:buffer].nil?
  end
  args["id"] = SecureRandom.uuid
  "#{request.upcase}=#{JSON.dump args}"
end

.readObject



2
3
4
5
# File 'lib/minep-request/minep.rb', line 2

def self.read
  input = $stdin.readline
  input = input.strip
end