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
98 99 100 101 |
# File 'lib/wikidata_position_history/report.rb', line 98 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.
103 104 105 |
# File 'lib/wikidata_position_history/report.rb', line 103 def position_id @position_id end |
#template_class ⇒ Object (readonly)
Returns the value of attribute template_class.
103 104 105 |
# File 'lib/wikidata_position_history/report.rb', line 103 def template_class @template_class end |
Instance Method Details
#header ⇒ Object
112 113 114 |
# File 'lib/wikidata_position_history/report.rb', line 112 def header "== {{Q|#{position_id}}} officeholders #{position_dates} ==" end |
#position_dates ⇒ Object
116 117 118 119 120 121 |
# File 'lib/wikidata_position_history/report.rb', line 116 def position_dates dates = [.inception.date, .abolition.date] return '' if dates.compact.empty? format('(%s)', dates.join(' – ')) end |
#template_params ⇒ Object
127 128 129 130 131 132 133 |
# File 'lib/wikidata_position_history/report.rb', line 127 def template_params { metadata: , table_rows: table_rows, sparql_url: sparql.wdqs_url, } end |
#wikitext ⇒ Object
105 106 107 108 109 110 |
# File 'lib/wikidata_position_history/report.rb', line 105 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
123 124 125 |
# File 'lib/wikidata_position_history/report.rb', line 123 def wikitext_with_header [header, wikitext].join("\n") end |