Class: CPEE::Frames::GetFrames

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

Overview

{{{

Instance Method Summary collapse

Instance Method Details

#responseObject



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/cpee-frames/implementation.rb', line 242

def response
  data_dir = @a[0]
  fname = File.join(data_dir,@r[-2],'frames.json')
  if File.exist? fname

    infofile = File.join(data_dir,@r[-2],'info.json')
    infojson = JSON::parse(File.read(infofile))

    #remove not used languages
    file = JSON::parse(File.read(fname))

    file["data"].each do |child|
      child["url"] = child["url"].find{ |h| h['lang'] == infojson["lang"]}['url']
    end

    Riddl::Parameter::Complex.new('value','application/json',JSON.dump(file))
  else
    @status = 404
  end
end