Module: Parliament::Grom::Decorator::ConstituencyGroup

Defined in:
lib/parliament/grom/decorator/constituency_group.rb

Overview

Decorator namespace for Grom::Node instances with type: id.ukpds.org/schema/ConstituencyGroup

Since:

  • 0.1.0

Instance Method Summary collapse

Instance Method Details

#areaGrom::Node?

Alias constituencyGroupHasConstituencyArea with fallback.

Returns:

Since:

  • 0.1.0



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

def area
  respond_to?(:constituencyGroupHasConstituencyArea) ? constituencyGroupHasConstituencyArea.first : nil
end

#contact_pointsArray

Alias incumbencyHasContactPoint with fallback.

Returns:

  • (Array, Array)

    the contact points of the Grom::Node or an empty array.

Since:

  • 0.1.0



72
73
74
75
76
77
78
79
80
81
# File 'lib/parliament/grom/decorator/constituency_group.rb', line 72

def contact_points
  return @contact_points unless @contact_points.nil?

  contact_points = []
  seat_incumbencies.each do |seat_incumbency|
    contact_points << seat_incumbency.contact_points
  end

  @contact_points = contact_points.flatten.uniq
end

#current?Boolean

Checks if Grom::Node has an end date.

Returns:

  • (Boolean)

    a boolean depending on whether or not the Grom::Node has an end date.

Since:

  • 0.1.0



86
87
88
89
90
# File 'lib/parliament/grom/decorator/constituency_group.rb', line 86

def current?
  has_end_date = respond_to?(:constituencyGroupEndDate)

  !has_end_date
end

#end_dateDateTime?

Alias constituencyGroupEndDate with fallback.

Returns:

  • (DateTime, nil)

    the end date of the Grom::Node or nil.

Since:

  • 0.1.0



23
24
25
# File 'lib/parliament/grom/decorator/constituency_group.rb', line 23

def end_date
  @end_date ||= respond_to?(:constituencyGroupEndDate) ? DateTime.parse(constituencyGroupEndDate) : nil
end

#membersArray

Alias incumbencyHasMember with fallback.

Returns:

  • (Array, Array)

    the members of the Grom::Node or an empty array.

Since:

  • 0.1.0



51
52
53
54
55
56
57
58
59
60
# File 'lib/parliament/grom/decorator/constituency_group.rb', line 51

def members
  return @members unless @members.nil?

  members = []
  seat_incumbencies.each do |seat_incumbency|
    members << seat_incumbency.member
  end

  @members = members.flatten.uniq
end

#nameString

Alias constituencyGroupName with fallback.

Returns:

  • (String, String)

    the name of the Grom::Node or an empty string.

Since:

  • 0.1.0



9
10
11
# File 'lib/parliament/grom/decorator/constituency_group.rb', line 9

def name
  respond_to?(:constituencyGroupName) ? constituencyGroupName : ''
end

#seat_incumbenciesArray

Alias houseSeatHasSeatIncumbency with fallback.

Returns:

  • (Array, Array)

    the seat incumbencies of the Grom::Node or an empty array.

Since:

  • 0.1.0



37
38
39
40
41
42
43
44
45
46
# File 'lib/parliament/grom/decorator/constituency_group.rb', line 37

def seat_incumbencies
  return @seat_incumbencies unless @seat_incumbencies.nil?

  seat_incumbencies = []
  seats.each do |seat|
    seat_incumbencies << seat.seat_incumbencies
  end

  @seat_incumbencies = seat_incumbencies.flatten.uniq
end

#seatsArray

Alias constituencyGroupHasHouseSeat with fallback.

Returns:

  • (Array, Array)

    the house seats of the Grom::Node or an empty array.

Since:

  • 0.1.0



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

def seats
  respond_to?(:constituencyGroupHasHouseSeat) ? constituencyGroupHasHouseSeat : []
end

#start_dateDateTime?

Alias constituencyGroupStartDate with fallback.

Returns:

  • (DateTime, nil)

    the start date of the Grom::Node or nil.

Since:

  • 0.1.0



16
17
18
# File 'lib/parliament/grom/decorator/constituency_group.rb', line 16

def start_date
  @start_date ||= respond_to?(:constituencyGroupStartDate) ? DateTime.parse(constituencyGroupStartDate) : nil
end