Module: Parliament::Grom::Decorator::BusinessItem
- Includes:
- Helpers::DateHelper
- Defined in:
- lib/parliament/grom/decorator/business_item.rb
Overview
Decorator namespace for Grom::Node instances with type: id.parliament.uk/schema/BusinessItem
Instance Method Summary collapse
-
#date ⇒ Date?
Alias businessItemDate with fallback.
-
#procedure_steps ⇒ Array
Alias businessItemHasProcedureStep with fallback.
-
#shortest_distance_of_procedure_steps ⇒ Integer?
Finds, for each of the procedure steps belonging to a business item, the shortest distance from origin.
-
#sorted_procedure_steps_by_distance ⇒ Array
Each procedure step has a distance from origin.
-
#weblink ⇒ String
Alias businessItemHasBusinessItemWebLink with fallback.
Methods included from Helpers::DateHelper
Instance Method Details
#date ⇒ Date?
Alias businessItemDate with fallback.
31 32 33 |
# File 'lib/parliament/grom/decorator/business_item.rb', line 31 def date respond_to?(:businessItemDate) ? DateTime.parse(businessItemDate) : nil end |
#procedure_steps ⇒ Array
Alias businessItemHasProcedureStep with fallback.
10 11 12 |
# File 'lib/parliament/grom/decorator/business_item.rb', line 10 def procedure_steps respond_to?(:businessItemHasProcedureStep) ? businessItemHasProcedureStep : [] end |
#shortest_distance_of_procedure_steps ⇒ Integer?
Finds, for each of the procedure steps belonging to a business item, the shortest distance from origin
24 25 26 |
# File 'lib/parliament/grom/decorator/business_item.rb', line 24 def shortest_distance_of_procedure_steps sorted_procedure_steps_by_distance.first&.distance_from_origin end |
#sorted_procedure_steps_by_distance ⇒ Array
Each procedure step has a distance from origin
17 18 19 |
# File 'lib/parliament/grom/decorator/business_item.rb', line 17 def sorted_procedure_steps_by_distance procedure_steps.sort_by(&:distance_from_origin) end |
#weblink ⇒ String
Alias businessItemHasBusinessItemWebLink with fallback.
38 39 40 |
# File 'lib/parliament/grom/decorator/business_item.rb', line 38 def weblink respond_to?(:businessItemHasBusinessItemWebLink) ? businessItemHasBusinessItemWebLink : '' end |