Class: WikidataPositionHistory::Report

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

Overview

The entire wikitext generated for this report

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(position_id, template_class = ReportTemplate) ⇒ Report

Returns a new instance of Report.



149
150
151
152
# File 'lib/wikidata_position_history/report.rb', line 149

def initialize(position_id, template_class = ReportTemplate)
  @position_id = position_id
  @template_class = template_class
end

Instance Attribute Details

#position_idObject (readonly)

Returns the value of attribute position_id.



154
155
156
# File 'lib/wikidata_position_history/report.rb', line 154

def position_id
  @position_id
end

#template_classObject (readonly)

Returns the value of attribute template_class.



154
155
156
# File 'lib/wikidata_position_history/report.rb', line 154

def template_class
  @template_class
end

Instance Method Details

#template_paramsObject



164
165
166
167
168
169
170
# File 'lib/wikidata_position_history/report.rb', line 164

def template_params
  {
    metadata:   ,
    table_rows: table_rows,
    sparql_url: sparql.wdqs_url,
  }
end

#wikitextObject



156
157
158
159
160
161
162
# File 'lib/wikidata_position_history/report.rb', line 156

def wikitext
  return legislator_template if .legislator?
  return config.multimember_error_template if .constituency? && (.representative_count != 1)
  return no_items_output if mandates.empty?

  template_class.new(template_params).output
end