Class: WikidataPositionHistory::Report
- Inherits:
-
Object
- Object
- WikidataPositionHistory::Report
- Defined in:
- lib/wikidata_position_history/report.rb
Overview
The entire wikitext generated for this report
Instance Attribute Summary collapse
-
#position_id ⇒ Object
readonly
Returns the value of attribute position_id.
-
#template_class ⇒ Object
readonly
Returns the value of attribute template_class.
Instance Method Summary collapse
- #header ⇒ Object
-
#initialize(position_id, template_class = ReportTemplate) ⇒ Report
constructor
A new instance of Report.
- #position_dates ⇒ Object
- #template_params ⇒ Object
- #wikitext ⇒ Object
- #wikitext_with_header ⇒ Object
Constructor Details
#initialize(position_id, template_class = ReportTemplate) ⇒ Report
Returns a new instance of Report.
114 115 116 117 |
# File 'lib/wikidata_position_history/report.rb', line 114 def initialize(position_id, template_class = ReportTemplate) @position_id = position_id @template_class = template_class end |
Instance Attribute Details
#position_id ⇒ Object (readonly)
Returns the value of attribute position_id.
119 120 121 |
# File 'lib/wikidata_position_history/report.rb', line 119 def position_id @position_id end |
#template_class ⇒ Object (readonly)
Returns the value of attribute template_class.
119 120 121 |
# File 'lib/wikidata_position_history/report.rb', line 119 def template_class @template_class end |
Instance Method Details
#header ⇒ Object
128 129 130 |
# File 'lib/wikidata_position_history/report.rb', line 128 def header "== {{Q|#{position_id}}} officeholders #{position_dates} ==" end |
#position_dates ⇒ Object
132 133 134 135 136 137 |
# File 'lib/wikidata_position_history/report.rb', line 132 def position_dates dates = [.inception_date, .abolition_date] return '' if dates.compact.empty? format('(%s)', dates.join(' – ')) end |
#template_params ⇒ Object
143 144 145 146 147 148 149 |
# File 'lib/wikidata_position_history/report.rb', line 143 def template_params { metadata: , table_rows: table_rows, sparql_url: sparql.wdqs_url, } end |
#wikitext ⇒ Object
121 122 123 124 125 126 |
# File 'lib/wikidata_position_history/report.rb', line 121 def wikitext return legislator_template if .legislator? return no_items_output if mandates.empty? template_class.new(template_params).output end |
#wikitext_with_header ⇒ Object
139 140 141 |
# File 'lib/wikidata_position_history/report.rb', line 139 def wikitext_with_header [header, wikitext].join("\n") end |