-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcookied_tool.rb
49 lines (44 loc) · 1.67 KB
/
cookied_tool.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class CookiedTool
attr_accessor :landing_path, :tool, :canonical_url
def initialize(landing_path:, tool:, canonical_url:)
@landing_path = landing_path
@tool = tool
@canonical_url = canonical_url
end
def landing_path_regex
%r{^#{landing_path}?$}
end
COOKIED_TOOLS = [
CookiedTool.new(
landing_path: '/en/tools/budget-planner/',
tool: 'budget-planner',
canonical_url: 'https://www.moneyhelper.org.uk/en/everyday-money/budgeting/use-our-budget-planner'
),
CookiedTool.new(
landing_path: '/en/tools/credit-card-calculator/credit-card/',
tool: 'credit-card-calculator',
canonical_url: 'https://www.moneyhelper.org.uk/en/everyday-money/credit-and-purchases/use-our-credit-card-calculator'
),
CookiedTool.new(
landing_path: '/en/tools/loan-calculator/loan/',
tool: 'loan-calculator',
canonical_url: 'https://www.moneyhelper.org.uk/en/everyday-money/credit-and-purchases/use-our-loan-calculator'
),
CookiedTool.new(
landing_path: '/en/tools/redundancy-pay-calculator/',
tool: 'redundancy-pay-calculator',
canonical_url: 'https://www.moneyhelper.org.uk/en/work/losing-your-job/use-our-redundancy-pay-calculator'
),
CookiedTool.new(
landing_path: '/en/tools/workplace-pension-contribution-calculator/',
tool: 'wpcc',
canonical_url: 'https://www.moneyhelper.org.uk/en/pensions-and-retirement/auto-enrolment/use-our-workplace-pension-calculator'
)
].freeze
def self.find_by_landing_path(path)
COOKIED_TOOLS.find { |tool| tool.landing_path_regex === path }
end
def self.find_by_tool(id)
COOKIED_TOOLS.find { |tool| tool.tool == id }
end
end