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
73
74
75
|
# File 'lib/wikidata_position_history/checks.rb', line 73
def expect_end_date?
later
end
|
#expect_next? ⇒ Boolean
84
85
86
87
88
89
|
# File 'lib/wikidata_position_history/checks.rb', line 84
def expect_next?
return unless later
return if later.item == current.item
!current.acting?
end
|
#expect_prev? ⇒ Boolean
77
78
79
80
81
82
|
# File 'lib/wikidata_position_history/checks.rb', line 77
def expect_prev?
return unless earlier
return if earlier.item == current.item
!current.acting?
end
|
#expect_start_date? ⇒ Boolean
69
70
71
|
# File 'lib/wikidata_position_history/checks.rb', line 69
def expect_start_date?
true
end
|
#expected ⇒ Object
65
66
67
|
# File 'lib/wikidata_position_history/checks.rb', line 65
def expected
field_map.keys.select { |field| send("expect_#{field}?") }
end
|
#field_map ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'lib/wikidata_position_history/checks.rb', line 56
def field_map
{
start_date: 580,
prev: 1365,
end_date: 582,
next: 1366,
}
end
|
#headline ⇒ Object
44
45
46
|
# File 'lib/wikidata_position_history/checks.rb', line 44
def headline
"Missing field#{missing.count > 1 ? 's' : ''}"
end
|
#missing ⇒ Object
52
53
54
|
# File 'lib/wikidata_position_history/checks.rb', line 52
def missing
expected.reject { |field| current.send(field) }
end
|
#possible_explanation ⇒ Object
48
49
50
|
# File 'lib/wikidata_position_history/checks.rb', line 48
def possible_explanation
"#{current.item} is missing #{missing.map { |field| "{{P|#{field_map[field]}}}" }.join(', ')}"
end
|
#problem? ⇒ Boolean
40
41
42
|
# File 'lib/wikidata_position_history/checks.rb', line 40
def problem?
missing.any?
end
|