Class: WikidataPositionHistory::Metadata
- Inherits:
-
Object
- Object
- WikidataPositionHistory::Metadata
- Defined in:
- lib/wikidata_position_history/report.rb
Overview
Data about the position itself, to be passed to the report template
Instance Method Summary collapse
- #abolition ⇒ Object
- #abolition_dates ⇒ Object
- #constituency? ⇒ Boolean
- #inception ⇒ Object
- #inception_dates ⇒ Object
-
#initialize(rows) ⇒ Metadata
constructor
A new instance of Metadata.
- #legislator? ⇒ Boolean
- #position ⇒ Object
- #position? ⇒ Boolean
- #predecessor ⇒ Object
- #replaced_by_combined ⇒ Object
- #replaces_combined ⇒ Object
- #representative_count ⇒ Object
- #successor ⇒ Object
Constructor Details
#initialize(rows) ⇒ Metadata
Returns a new instance of Metadata.
37 38 39 |
# File 'lib/wikidata_position_history/report.rb', line 37 def initialize(rows) @rows = rows end |
Instance Method Details
#abolition ⇒ Object
57 58 59 |
# File 'lib/wikidata_position_history/report.rb', line 57 def abolition @abolition ||= OutputRow::Abolition.new(self) end |
#abolition_dates ⇒ Object
92 93 94 |
# File 'lib/wikidata_position_history/report.rb', line 92 def abolition_dates rows.map(&:abolition_date).compact.uniq(&:to_s).sort end |
#constituency? ⇒ Boolean
71 72 73 74 |
# File 'lib/wikidata_position_history/report.rb', line 71 def constituency? # this should be the same everywhere rows.map(&:constituency?).first end |
#inception ⇒ Object
53 54 55 |
# File 'lib/wikidata_position_history/report.rb', line 53 def inception @inception ||= OutputRow::Inception.new(self) end |
#inception_dates ⇒ Object
88 89 90 |
# File 'lib/wikidata_position_history/report.rb', line 88 def inception_dates rows.map(&:inception_date).compact.uniq(&:to_s).sort end |
#legislator? ⇒ Boolean
66 67 68 69 |
# File 'lib/wikidata_position_history/report.rb', line 66 def legislator? # this should be the same everywhere rows.map(&:legislator?).first end |
#position ⇒ Object
41 42 43 |
# File 'lib/wikidata_position_history/report.rb', line 41 def position rows.map(&:item).first end |
#position? ⇒ Boolean
61 62 63 64 |
# File 'lib/wikidata_position_history/report.rb', line 61 def position? # this should be the same everywhere rows.map(&:position?).first end |
#predecessor ⇒ Object
45 46 47 |
# File 'lib/wikidata_position_history/report.rb', line 45 def predecessor @predecessor ||= OutputRow::Predecessor.new(self) end |
#replaced_by_combined ⇒ Object
84 85 86 |
# File 'lib/wikidata_position_history/report.rb', line 84 def replaced_by_combined @replaced_by_combined ||= ImpliedList.new(uniq_by_id(:replaced_by), uniq_by_id(:derived_replaced_by)) end |
#replaces_combined ⇒ Object
80 81 82 |
# File 'lib/wikidata_position_history/report.rb', line 80 def replaces_combined @replaces_combined ||= ImpliedList.new(uniq_by_id(:replaces), uniq_by_id(:derived_replaces)) end |
#representative_count ⇒ Object
76 77 78 |
# File 'lib/wikidata_position_history/report.rb', line 76 def representative_count rows.map(&:representative_count).max end |