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.

Since:

  • 0.1.0

Instance Method Summary collapse

Methods included from Helpers::DateHelper

#date_range

Instance Method Details

#chair_peopleArray

Returns array of Person Grom::Node(s) representing the current incumbent(s) of chair position(s).

Since:

  • 0.1.0



30
31
32
# File 'lib/parliament/grom/decorator/formal_body.rb', line 30

def chair_people
  chairs.first&.incumbencies&.first&.people || []
end

#chairsArray

Alias is_chair with fallback.

Since:

  • 0.1.0



25
26
27
# File 'lib/parliament/grom/decorator/formal_body.rb', line 25

def chairs
  respond_to?(:formalBodyHasFormalBodyChair) ? formalBodyHasFormalBodyChair : []
end

#committee_typeString

Checks what type of committee a Grom::Node represents. TODO: Build out as the types of possible committee types grows

Since:

  • 0.1.0



94
95
96
# File 'lib/parliament/grom/decorator/formal_body.rb', line 94

def committee_type
  select_committee? ? 'select' : ''
end

#contact_pointsArray

Checks if Grom::Node has contact points.

Since:

  • 0.1.0



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.

Since:

  • 0.1.0



65
66
67
# File 'lib/parliament/grom/decorator/formal_body.rb', line 65

def current?
  end_date.nil?
end

#end_dateDateTime?

Alias formalBodyEndDate with fallback.

Since:

  • 0.1.0



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.

Since:

  • 0.1.0



18
19
20
# File 'lib/parliament/grom/decorator/formal_body.rb', line 18

def has_chair?
  respond_to?(:formalBodyHasFormalBodyChair)
end

#housesArray

Checks if Grom::Node has a house.

Since:

  • 0.1.0



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.

Since:

  • 0.1.0



51
52
53
# File 'lib/parliament/grom/decorator/formal_body.rb', line 51

def joint?
  respond_to?(:formalBodyHasLeadHouse)
end

#nameString

Checks if Grom::Node has a name.

Since:

  • 0.1.0



11
12
13
# File 'lib/parliament/grom/decorator/formal_body.rb', line 11

def name
  @name ||= respond_to?(:formalBodyName) ? formalBodyName : ''
end

#remitString

Checks if Grom::Node has a remit.

Since:

  • 0.1.0



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.

Since:

  • 0.1.0



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_dateDateTime?

Alias formalBodyStartDate with fallback.

Since:

  • 0.1.0



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