Class: WikidataPositionHistory::OutputRow::Mandate

Inherits:
Object
  • Object
show all
Defined in:
lib/wikidata_position_history/output_row.rb

Overview

Date for a single mandate row, to be passed to the report template

Constant Summary collapse

CHECKS =
[Check::MissingFields, Check::Overlap,
Check::WrongPredecessor, Check::MissingPredecessor,
Check::WrongSuccessor, Check::MissingSuccessor].freeze

Instance Method Summary collapse

Constructor Details

#initialize(later, current, earlier) ⇒ Mandate

Returns a new instance of Mandate.



14
15
16
17
18
# File 'lib/wikidata_position_history/output_row.rb', line 14

def initialize(later, current, earlier)
  @later = later
  @current = current
  @earlier = earlier
end

Instance Method Details

#acting?Boolean

Returns:

  • (Boolean)


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

def acting?
  current.acting?
end

#datesObject



33
34
35
36
37
38
# File 'lib/wikidata_position_history/output_row.rb', line 33

def dates
  dates = [current.start_date, current.end_date]
  return '' if dates.compact.empty?

  dates.join('')
end

#officeholderObject



29
30
31
# File 'lib/wikidata_position_history/output_row.rb', line 29

def officeholder
  current.officeholder
end

#ordinal_stringObject



20
21
22
23
# File 'lib/wikidata_position_history/output_row.rb', line 20

def ordinal_string
  ordinal = current.ordinal or return ''
  "#{ordinal}."
end

#partyObject



25
26
27
# File 'lib/wikidata_position_history/output_row.rb', line 25

def party
  current.party
end

#warningsObject



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

def warnings
  CHECKS.map { |klass| klass.new(later, current, earlier) }.select(&:problem?)
end