Class: CPEE::Frames::DeleteFrame

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

Instance Method Summary collapse

Instance Method Details

#responseObject



206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/cpee-frames/implementation.rb', line 206

def response
  data_dir = @a[1]
  path = File.join(data_dir,@r.last,'frames.json')
  file = File.read(path)
  data_hash = JSON::parse(file)

  data_hash["data"].each do | c |
    if CPEE::Frames::overlap?(c['lx'], c['ly'], c['rx'], c['ry'], @p[0].value.to_i, @p[1].value.to_i, (@p[0].value.to_i + 1), (@p[1].value.to_i + 1))
      data_hash["data"].delete(c)
    end
  end

  File.write(path, JSON.dump(data_hash))
end