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



198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/cpee-frames/implementation.rb', line 198

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