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.
43 44 45 |
# File 'lib/wikidata_position_history/report.rb', line 43 def initialize(rows) @rows = rows end |
Instance Method Details
#abolition ⇒ Object
63 64 65 |
# File 'lib/wikidata_position_history/report.rb', line 63 def abolition @abolition ||= OutputRow::Abolition.new(self) end |
#abolition_dates ⇒ Object
98 99 100 |
# File 'lib/wikidata_position_history/report.rb', line 98 def abolition_dates rows.map(&:abolition_date).compact.uniq(&:to_s).sort end |
#constituency? ⇒ Boolean
77 78 79 80 |
# File 'lib/wikidata_position_history/report.rb', line 77 def constituency? # this should be the same everywhere rows.map(&:constituency?).first end |
#inception ⇒ Object
59 60 61 |
# File 'lib/wikidata_position_history/report.rb', line 59 def inception @inception ||= OutputRow::Inception.new(self) end |
#inception_dates ⇒ Object
94 95 96 |
# File 'lib/wikidata_position_history/report.rb', line 94 def inception_dates rows.map(&:inception_date).compact.uniq(&:to_s).sort end |
#legislator? ⇒ Boolean
72 73 74 75 |
# File 'lib/wikidata_position_history/report.rb', line 72 def legislator? # this should be the same everywhere rows.map(&:legislator?).first end |
#position ⇒ Object
47 48 49 |
# File 'lib/wikidata_position_history/report.rb', line 47 def position rows.map(&:item).first end |
#position? ⇒ Boolean
67 68 69 70 |
# File 'lib/wikidata_position_history/report.rb', line 67 def position? # this should be the same everywhere rows.map(&:position?).first end |
#predecessor ⇒ Object
51 52 53 |
# File 'lib/wikidata_position_history/report.rb', line 51 def predecessor @predecessor ||= OutputRow::Predecessor.new(self) end |
#replaced_by_combined ⇒ Object
90 91 92 |
# File 'lib/wikidata_position_history/report.rb', line 90 def replaced_by_combined @replaced_by_combined ||= ImpliedList.new(uniq_by_id(:replaced_by), uniq_by_id(:derived_replaced_by)) end |
#replaces_combined ⇒ Object
86 87 88 |
# File 'lib/wikidata_position_history/report.rb', line 86 def replaces_combined @replaces_combined ||= ImpliedList.new(uniq_by_id(:replaces), uniq_by_id(:derived_replaces)) end |
#representative_count ⇒ Object
82 83 84 |
# File 'lib/wikidata_position_history/report.rb', line 82 def representative_count rows.map(&:representative_count).max end |