Module: Parliament::Utils::Helpers::HousesHelper
- Defined in:
- lib/parliament/utils/helpers/houses_helper.rb
Class Method Summary collapse
-
.commons?(house) ⇒ Boolean
Checks if house is the House of Commons and sets @commons_id and @lords_id if not already set.
-
.commons_id ⇒ String
Sets and returns the id for the House of Commons.
-
.house_id_string(house) ⇒ Array<String, String>
Returns the current house id for the page alongside the other house id.
-
.lords?(house) ⇒ Boolean
Checks if house is the House of Lords and sets @commons_id and @lords_id if not already set.
-
.lords_id ⇒ String
Sets and returns the id for the House of Lords.
-
.person_type_string(house) ⇒ Array<String, String>
Returns the current.
- .set_ids ⇒ Object
Class Method Details
.commons?(house) ⇒ Boolean
Checks if house is the House of Commons and sets @commons_id and @lords_id if not already set.
10 11 12 13 14 |
# File 'lib/parliament/utils/helpers/houses_helper.rb', line 10 def commons?(house) set_ids house&.graph_id == @commons_id end |
.commons_id ⇒ String
Sets and returns the id for the House of Commons.
29 30 31 32 33 |
# File 'lib/parliament/utils/helpers/houses_helper.rb', line 29 def commons_id set_ids @commons_id end |
.house_id_string(house) ⇒ Array<String, String>
Returns the current house id for the page alongside the other house id.
48 49 50 51 52 53 54 55 |
# File 'lib/parliament/utils/helpers/houses_helper.rb', line 48 def house_id_string(house) is_commons = commons?(house) house_ids = [commons_id, lords_id] return house_ids if is_commons house_ids.reverse end |
.lords?(house) ⇒ Boolean
Checks if house is the House of Lords and sets @commons_id and @lords_id if not already set.
20 21 22 23 24 |
# File 'lib/parliament/utils/helpers/houses_helper.rb', line 20 def lords?(house) return false if house.nil? !commons?(house) end |
.lords_id ⇒ String
Sets and returns the id for the House of Lords.
38 39 40 41 42 |
# File 'lib/parliament/utils/helpers/houses_helper.rb', line 38 def lords_id set_ids @lords_id end |
.person_type_string(house) ⇒ Array<String, String>
Returns the current
61 62 63 64 65 66 67 68 69 |
# File 'lib/parliament/utils/helpers/houses_helper.rb', line 61 def person_type_string(house) is_mp = commons?(house) types = [I18n.t('mp_plural'), I18n.t('lord_plural')] return types if is_mp types.reverse end |
.set_ids ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/parliament/utils/helpers/houses_helper.rb', line 73 def set_ids return if @commons_id && @lords_id houses = Parliament::Utils::Helpers::ParliamentHelper.parliament_request.house_index.get.filter('https://id.parliament.uk/schema/House').sort_by(:name) @commons_id = houses.first.graph_id @lords_id = houses.last.graph_id end |