-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiof_result_list_classes.rb
133 lines (111 loc) · 2.79 KB
/
iof_result_list_classes.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
class PersonResult
attr_accessor :person_id
attr_accessor :family_name
attr_accessor :given_name
attr_accessor :birth_year
attr_accessor :club_id
attr_accessor :club_name
attr_accessor :club_short_name
attr_accessor :time
attr_accessor :state
attr_accessor :position
attr_accessor :rank_value
def initialize
@rank_value = 0
end
def full_name
fname = family_name
if fname =~ /^\w+$/
fname.capitalize!
end
"#{given_name} #{fname}"
end
def get_position
if position.nil? || position.empty?
#puts state.to_s
if ak()
return "AK"
elsif state.to_s == "MisPunch"
return "Fehlst"
elsif state.to_s == "DidNotFinish" || state.to_s == "SportWithdr"
return "Aufg"
elsif did_not_start()
return "N Ang"
elsif state.to_s == "Disqualified"
return "Disq"
elsif state.to_s == "OverTime"
return "Lim"
else
return state.to_s
end
end
position.to_s
end
def did_not_start
state.to_s == "DidNotStart" || state.to_s == "Cancelled"
end
def ak
state.to_s == "OK" || state.to_s == "NotCompeting"
end
def real_position
return true if get_position =~ /^\d+$/
false
end
def real_or_ak_position
pos = get_position
return pos if pos =~ /^\d+$/
return pos if pos =~ /AK/
nil
end
def real_or_ak_position_to_s
pos = real_position
return pos.to_s if pos
""
end
HIGH_POSITION = 9999999
def integer_position
if position.nil? || position.empty?
return ak ? HIGH_POSITION-1 : (did_not_start ? HIGH_POSITION+1 : HIGH_POSITION)
end
position
end
def get_club_name
return club_short_name.to_s if !club_short_name.nil?
return club_name.to_s if !club_name.nil?
club_id.to_s
end
end
class EventClass
attr_accessor :name
attr_accessor :best_time
attr_accessor :results
attr_accessor :length
attr_accessor :control_count
def ignore_in_nor
return true if name == "BK" || name == "Beg" || name == "BL" || name == "Trim" || name == "Beginner Kurz" || name == "Beginner Lang"
end
def ignore_in_nebel
return true if name == "BK" || name == "Beg" || name == "BL" || name == "Trimm"
end
def ignore_in_kristall
return true if name == "BK" || name == "Beg" || name == "BL" || name == "Trimm"
end
def ignore_in_rank_mode(rank_mode)
ignore_in_nor if rank_mode == :nor
ignore_in_nebel if rank_mode == :nebel
ignore_in_kristall if rank_mode == :kristall
end
end
class Event
attr_accessor :name
attr_accessor :event_classes
end
def name_from_filename(name)
File.basename(name, File.extname(name))
end
def filename_from_name(name)
prepare_filename(name_from_filename(name))
end
def prepare_filename(name)
name.gsub("\s", "_").gsub("/","_").gsub("\\","_").downcase
end