Module: Parliament::Grom::Decorator::FormalBody
- Includes:
- Helpers::DateHelper
- Defined in:
- lib/parliament/grom/decorator/formal_body.rb
Overview
Decorator namespace for Grom::Node instances with type: id.parliament.uk/schema/FormalBody.
Instance Method Summary collapse
-
#chair_people ⇒ Array
Array of Person Grom::Node(s) representing the current incumbent(s) of chair position(s).
-
#chairs ⇒ Array
Alias is_chair with fallback.
-
#committee_type ⇒ String
Checks what type of committee a Grom::Node represents.
-
#contact_points ⇒ Array
Checks if Grom::Node has contact points.
-
#current? ⇒ Boolean
Checks if Grom::Node has an end date.
-
#end_date ⇒ DateTime?
Alias formalBodyEndDate with fallback.
-
#has_chair? ⇒ Boolean
Checks if Grom::Node has a chair.
-
#houses ⇒ Array
Checks if Grom::Node has a house.
-
#joint? ⇒ Boolean
Checks if Grom::Node is joint.
-
#name ⇒ String
Checks if Grom::Node has a name.
-
#remit ⇒ String
Checks if Grom::Node has a remit.
-
#select_committee? ⇒ Boolean
Checks if the type of Grom::Node is a select committee.
-
#start_date ⇒ DateTime?
Alias formalBodyStartDate with fallback.
Methods included from Helpers::DateHelper
Instance Method Details
#chair_people ⇒ Array
Returns array of Person Grom::Node(s) representing the current incumbent(s) of chair position(s).
30 31 32 |
# File 'lib/parliament/grom/decorator/formal_body.rb', line 30 def chair_people chairs.first&.incumbencies&.first&.people || [] end |
#chairs ⇒ Array
Alias is_chair with fallback.
25 26 27 |
# File 'lib/parliament/grom/decorator/formal_body.rb', line 25 def chairs respond_to?(:formalBodyHasFormalBodyChair) ? formalBodyHasFormalBodyChair : [] end |
#committee_type ⇒ String
Checks what type of committee a Grom::Node represents. TODO: Build out as the types of possible committee types grows
94 95 96 |
# File 'lib/parliament/grom/decorator/formal_body.rb', line 94 def committee_type select_committee? ? 'select' : '' end |
#contact_points ⇒ Array
Checks if Grom::Node has contact points.
72 73 74 |
# File 'lib/parliament/grom/decorator/formal_body.rb', line 72 def contact_points @contact_points ||= respond_to?(:formalBodyHasContactPoint) ? Array(formalBodyHasContactPoint) : [] end |
#current? ⇒ Boolean
Checks if Grom::Node has an end date.
65 66 67 |
# File 'lib/parliament/grom/decorator/formal_body.rb', line 65 def current? end_date.nil? end |
#end_date ⇒ DateTime?
Alias formalBodyEndDate with fallback.
58 59 60 |
# File 'lib/parliament/grom/decorator/formal_body.rb', line 58 def end_date @end_date ||= respond_to?(:formalBodyEndDate) ? DateTime.parse(formalBodyEndDate) : nil end |
#has_chair? ⇒ Boolean
Checks if Grom::Node has a chair.
18 19 20 |
# File 'lib/parliament/grom/decorator/formal_body.rb', line 18 def has_chair? respond_to?(:formalBodyHasFormalBodyChair) end |
#houses ⇒ Array
Checks if Grom::Node has a house.
79 80 81 |
# File 'lib/parliament/grom/decorator/formal_body.rb', line 79 def houses respond_to?(:formalBodyHasHouse) ? formalBodyHasHouse : [] end |
#joint? ⇒ Boolean
Checks if Grom::Node is joint.
51 52 53 |
# File 'lib/parliament/grom/decorator/formal_body.rb', line 51 def joint? respond_to?(:formalBodyHasLeadHouse) end |
#name ⇒ String
Checks if Grom::Node has a name.
11 12 13 |
# File 'lib/parliament/grom/decorator/formal_body.rb', line 11 def name @name ||= respond_to?(:formalBodyName) ? formalBodyName : '' end |
#remit ⇒ String
Checks if Grom::Node has a remit.
44 45 46 |
# File 'lib/parliament/grom/decorator/formal_body.rb', line 44 def remit @remit ||= respond_to?(:formalBodyRemit) ? formalBodyRemit : '' end |
#select_committee? ⇒ Boolean
Checks if the type of Grom::Node is a select committee.
86 87 88 |
# File 'lib/parliament/grom/decorator/formal_body.rb', line 86 def select_committee? type.include?('https://id.parliament.uk/schema/SelectCommittee') end |
#start_date ⇒ DateTime?
Alias formalBodyStartDate with fallback.
37 38 39 |
# File 'lib/parliament/grom/decorator/formal_body.rb', line 37 def start_date @start_date ||= respond_to?(:formalBodyStartDate) ? DateTime.parse(formalBodyStartDate) : nil end |