Class: WikidataPositionHistory::Metadata

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

Overview

Data about the position itself, to be passed to the report template

Defined Under Namespace

Classes: Warning

Instance Method Summary collapse

Constructor Details

#initialize(rows) ⇒ Metadata

Returns a new instance of Metadata.



50
51
52
# File 'lib/wikidata_position_history/report.rb', line 50

def initialize(rows)
  @rows = rows
end

Instance Method Details

#abolition_dateObject



73
74
75
76
77
# File 'lib/wikidata_position_history/report.rb', line 73

def abolition_date
  return if abolition_dates.empty?

  abolition_dates.join(' / ')
end

#abolition_warningObject



79
80
81
82
83
# File 'lib/wikidata_position_history/report.rb', line 79

def abolition_warning
  return unless abolition_dates.count > 1

  Warning.new('Multiple values', "#{item_qlink} has more than one {{P|576}}")
end

#inception_dateObject



58
59
60
61
62
# File 'lib/wikidata_position_history/report.rb', line 58

def inception_date
  return if inception_dates.empty?

  inception_dates.join(' / ')
end

#inception_warningObject



64
65
66
67
68
69
70
71
# File 'lib/wikidata_position_history/report.rb', line 64

def inception_warning
  count = inception_dates.count

  return if count == 1
  return Warning.new('Missing field', "#{item_qlink} is missing {{P|571}}") if count.zero?

  Warning.new('Multiple values', "#{item_qlink} has more than one {{P|571}}")
end

#itemObject



54
55
56
# File 'lib/wikidata_position_history/report.rb', line 54

def item
  rows.map(&:item).first
end

#legislator?Boolean

Returns:

  • (Boolean)


90
91
92
93
# File 'lib/wikidata_position_history/report.rb', line 90

def legislator?
  # this should be the same everywhere
  rows.map(&:legislator?).first
end

#position?Boolean

Returns:

  • (Boolean)


85
86
87
88
# File 'lib/wikidata_position_history/report.rb', line 85

def position?
  # this should be the same everywhere
  rows.map(&:position?).first
end