Module: Parliament::Grom::Decorator::ParliamentPeriod
- Includes:
- Helpers::DateHelper
- Defined in:
- lib/parliament/grom/decorator/parliaments.rb
Overview
Decorator namespace for Grom::Node instances with type: id.parliament.uk/schema/Parliaments
Instance Method Summary collapse
-
#current? ⇒ Boolean
Checks if Grom::Node is current - ie.
-
#end_date ⇒ DateTime?
Alias parliamentPeriodEndDate with fallback.
-
#next_parliament? ⇒ true, false
Checks whether ParliamentPeriod has a next Parliament.
-
#number ⇒ Integer?
Alias parliamentPeriodNumber with fallback.
-
#previous_parliament? ⇒ true, false
Checks whether ParliamentPeriod has a previous Parliament.
-
#start_date ⇒ DateTime?
Alias parliamentPeriodStartDate with fallback.
Methods included from Helpers::DateHelper
Instance Method Details
#current? ⇒ Boolean
Checks if Grom::Node is current - ie. it has a start date in the past or today and an end date which is nil, today or in the future.
46 47 48 |
# File 'lib/parliament/grom/decorator/parliaments.rb', line 46 def current? (!start_date.nil? && start_date <= Date.today) && (end_date.nil? || end_date >= Date.today) end |
#end_date ⇒ DateTime?
Alias parliamentPeriodEndDate with fallback.
18 19 20 |
# File 'lib/parliament/grom/decorator/parliaments.rb', line 18 def end_date @end_date ||= respond_to?(:parliamentPeriodEndDate) ? DateTime.parse(parliamentPeriodEndDate) : nil end |
#next_parliament? ⇒ true, false
Checks whether ParliamentPeriod has a next Parliament
32 33 34 |
# File 'lib/parliament/grom/decorator/parliaments.rb', line 32 def next_parliament? respond_to?(:parliamentPeriodHasImmediatelyFollowingParliamentPeriod) end |
#number ⇒ Integer?
Alias parliamentPeriodNumber with fallback.
25 26 27 |
# File 'lib/parliament/grom/decorator/parliaments.rb', line 25 def number @number ||= respond_to?(:parliamentPeriodNumber) ? parliamentPeriodNumber.to_i : nil end |
#previous_parliament? ⇒ true, false
Checks whether ParliamentPeriod has a previous Parliament
39 40 41 |
# File 'lib/parliament/grom/decorator/parliaments.rb', line 39 def previous_parliament? respond_to?(:parliamentPeriodHasImmediatelyPreviousParliamentPeriod) end |
#start_date ⇒ DateTime?
Alias parliamentPeriodStartDate with fallback.
11 12 13 |
# File 'lib/parliament/grom/decorator/parliaments.rb', line 11 def start_date @start_date ||= respond_to?(:parliamentPeriodStartDate) ? DateTime.parse(parliamentPeriodStartDate) : nil end |