Class: WikidataPositionHistory::Check::MissingFields

Inherits:
WikidataPositionHistory::Check show all
Defined in:
lib/wikidata_position_history/checks.rb

Overview

Does the Officeholder have all the properties we expect?

Instance Method Summary collapse

Methods inherited from WikidataPositionHistory::Check

#explanation, #initialize

Constructor Details

This class inherits a constructor from WikidataPositionHistory::Check

Instance Method Details

#expect_end_date?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/wikidata_position_history/checks.rb', line 73

def expect_end_date?
  later
end

#expect_next?Boolean

Returns:

  • (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 # sucessive terms by same person

  !current.acting?
end

#expect_prev?Boolean

Returns:

  • (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 # sucessive terms by same person

  !current.acting?
end

#expect_start_date?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/wikidata_position_history/checks.rb', line 69

def expect_start_date?
  true
end

#expectedObject



65
66
67
# File 'lib/wikidata_position_history/checks.rb', line 65

def expected
  field_map.keys.select { |field| send("expect_#{field}?") }
end

#field_mapObject



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

#headlineObject



44
45
46
# File 'lib/wikidata_position_history/checks.rb', line 44

def headline
  "Missing field#{missing.count > 1 ? 's' : ''}"
end

#missingObject



52
53
54
# File 'lib/wikidata_position_history/checks.rb', line 52

def missing
  expected.reject { |field| current.send(field) }
end

#possible_explanationObject



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

Returns:

  • (Boolean)


40
41
42
# File 'lib/wikidata_position_history/checks.rb', line 40

def problem?
  missing.any?
end