Class: CPEE::Frames::SetLang

Inherits:
Riddl::Implementation
  • Object
show all
Defined in:
lib/cpee-frames/implementation.rb

Overview

}}}

Instance Method Summary collapse

Instance Method Details

#responseObject

{{{



328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
# File 'lib/cpee-frames/implementation.rb', line 328

def response
  data_dir = @a[1]
  fname = File.join(data_dir,@r[-2],'info.json')
  if File.exist? fname
    infojson = JSON::parse(File.read(fname))
    infojson["lang"] = @p[0].value


    #add to langs
    if !infojson["langs"].include?(@p[0].value)
      infojson["langs"].push(@p[0].value)
    end

    File.write(fname, JSON.dump(infojson))



    @a[0].send('reset')
    nil
  else
    @status = 404
  end
end