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
|
# File 'app/models/memory.rb', line 68
def set_base_year
types = %w(Resurrection Repose Writing Appearance Translation Sanctification)
event = self.events.to_a.sort_by { |x| (types.index(x.type) || 100) }.first
dates = event.happened_at.split(/[\/-]/)
self.base_year ||=
case dates.first
when /([IVX]+)$/
($1.rom - 1) * 100 + 50
when /\.\s*(\d+)$/
$1
when /(?:\A|\s|\()(\d+)$/
$1
when /(?:\A|\s|\(|\.)(\d+) до (?:нэ|РХ)/
"-#{$1}"
when /(:|сент)/
dates.last.split(".").last
when /давно/
'-3760'
else
dates = event.happened_at.split(/[\/-]/)
if /(?:\A|\s|\(|\.)(\d+) до (?:нэ|РХ)/ =~ dates.first
"-#{$1}"
else
'0' ;end;end
self.base_year ;end
|