]> git.openstreetmap.org Git - rails.git/blob - app/models/gpx_import_notification_details.rb
Merge remote-tracking branch 'upstream/pull/7245'
[rails.git] / app / models / gpx_import_notification_details.rb
1 # frozen_string_literal: true
2
3 class GpxImportNotificationDetails
4   class Details
5     def initialize(notification)
6       @notification = notification
7     end
8
9     delegate :record, :to => :@notification
10   end
11
12   class Success < Details
13     delegate :description, :tagstring, :to => :record
14
15     def filename
16       record.name
17     end
18
19     def num_tags
20       record.tags.length
21     end
22
23     def possible_points
24       @notification.params[:possible_points]
25     end
26
27     def trace_points
28       record.size
29     end
30   end
31
32   class Failure < Details
33     def filename
34       @notification.params[:trace_name]
35     end
36
37     def description
38       @notification.params[:trace_description]
39     end
40
41     def num_tags
42       tags.count
43     end
44
45     def tags
46       @notification.params[:trace_tags]
47     end
48
49     def tagstring
50       tags.join(", ")
51     end
52
53     def possible_points
54       nil
55     end
56
57     def trace_points
58       nil
59     end
60   end
61 end