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



192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/cpee-frames/implementation.rb', line 192

def response
  path = File.join('data',@r.last,'frames.json')
  file = File.read(path)
  data_hash = JSON::parse(file)

  data_hash["data"].each do | c |
    if doOverlap(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