Class: WikidataPositionHistory::Check::MissingFields
Overview
Does the Officeholder have all the properties we expect?
Instance Method Summary
collapse
#explanation, #initialize
Instance Method Details
#expect_end_date? ⇒ Boolean
74
75
76
|
# File 'lib/wikidata_position_history/checks.rb', line 74
def expect_end_date?
later
end
|
#expect_next? ⇒ Boolean
85
86
87
88
89
90
|
# File 'lib/wikidata_position_history/checks.rb', line 85
def expect_next?
return unless later
return if later.officeholder.id == current.officeholder.id
!current.acting?
end
|
#expect_prev? ⇒ Boolean
78
79
80
81
82
83
|
# File 'lib/wikidata_position_history/checks.rb', line 78
def expect_prev?
return unless earlier
return if earlier.officeholder.id == current.officeholder.id
!current.acting?
end
|
#expect_start_date? ⇒ Boolean
70
71
72
|
# File 'lib/wikidata_position_history/checks.rb', line 70
def expect_start_date?
true
end
|
#expected ⇒ Object
66
67
68
|
# File 'lib/wikidata_position_history/checks.rb', line 66
def expected
field_map.keys.select { |field| send("expect_#{field}?") }
end
|
#field_map ⇒ Object
57
58
59
60
61
62
63
64
|
# File 'lib/wikidata_position_history/checks.rb', line 57
def field_map
{
start_date: 580,
prev: 1365,
end_date: 582,
next: 1366,
}
end
|
#headline ⇒ Object
45
46
47
|
# File 'lib/wikidata_position_history/checks.rb', line 45
def headline
"Missing field#{missing.count > 1 ? 's' : ''}"
end
|
#missing ⇒ Object
53
54
55
|
# File 'lib/wikidata_position_history/checks.rb', line 53
def missing
expected.reject { |field| current.send(field) }
end
|
#possible_explanation ⇒ Object
49
50
51
|
# File 'lib/wikidata_position_history/checks.rb', line 49
def possible_explanation
"#{current.officeholder.qlink} is missing #{missing.map { |field| "{{P|#{field_map[field]}}}" }.join(', ')}"
end
|
#problem? ⇒ Boolean
41
42
43
|
# File 'lib/wikidata_position_history/checks.rb', line 41
def problem?
missing.any?
end
|