Class: Checkoff::Internal::SearchUrl::SimpleParam::SimpleParam
- Inherits:
-
Object
- Object
- Checkoff::Internal::SearchUrl::SimpleParam::SimpleParam
- Defined in:
- lib/checkoff/internal/search_url/simple_param_converter.rb,
sig/checkoff.rbs
Overview
base class for handling different types of search url params
Direct Known Subclasses
AllTagsIds, AnyProjectsIds, AnyTagsIds, Approval, Completion, LocatedIn, Milestone, NotProjectsIds, NotTagsIds, PortfoliosIds, SearchedType, Sort, Subtask
Instance Attribute Summary collapse
- #key ⇒ String readonly
- #values ⇒ Array<String> readonly
Instance Method Summary collapse
-
#convert ⇒ ::Array[String]
@sg-ignore abstract method always raises; declared type documents the override contract, not this body.
-
#convert_from_projects_and_sections(verb) ⇒ ::Array[String]
@param
verb. -
#initialize(key:, values:) ⇒ SimpleParam
constructor
@param
key— the name of the search url param. -
#parse_projects_and_sections(projects, sections) ⇒ void
Inputs: 123_column_456 means "abc" project, "def" section 123 means "abc" project 123~456 means "abc" and "def" projects.
-
#single_value ⇒ String
@return — the single value of the search url param.
Constructor Details
#initialize(key:, values:) ⇒ SimpleParam
@param key — the name of the search url param
@param values — the values of the search url param
17 18 19 20 |
# File 'lib/checkoff/internal/search_url/simple_param_converter.rb', line 17 def initialize(key:, values:) @key = key @values = values end |
Instance Attribute Details
#key ⇒ String (readonly)
45 46 47 |
# File 'lib/checkoff/internal/search_url/simple_param_converter.rb', line 45 def key @key end |
#values ⇒ Array<String> (readonly)
48 49 50 |
# File 'lib/checkoff/internal/search_url/simple_param_converter.rb', line 48 def values @values end |
Instance Method Details
#convert ⇒ ::Array[String]
@sg-ignore abstract method always raises; declared type documents the override contract, not this body
38 39 40 |
# File 'lib/checkoff/internal/search_url/simple_param_converter.rb', line 38 def convert raise 'Implement me!' end |
#convert_from_projects_and_sections(verb) ⇒ ::Array[String]
@param verb
73 74 75 76 77 78 79 80 81 |
# File 'lib/checkoff/internal/search_url/simple_param_converter.rb', line 73 def convert_from_projects_and_sections(verb) projects = [] sections = [] parse_projects_and_sections(projects, sections) out = {} out["projects.#{verb}"] = projects.join(',') unless projects.empty? out["sections.#{verb}"] = sections.join(',') unless sections.empty? out.to_a.flatten end |
#parse_projects_and_sections(projects, sections) ⇒ void
This method returns an undefined value.
Inputs:
123_column_456 means "abc" project, "def" section
123 means "abc" project
123~456 means "abc" and "def" projects
@param projects
@param sections
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/checkoff/internal/search_url/simple_param_converter.rb', line 58 def parse_projects_and_sections(projects, sections) single_value.split('~').each do |project_section_pair| project, section = project_section_pair.split('_column_') raise "Invalid query string: #{project_section_pair}" if project.nil? if section.nil? projects << project else sections << section end end end |
#single_value ⇒ String
@return — the single value of the search url param
25 26 27 28 29 30 31 32 |
# File 'lib/checkoff/internal/search_url/simple_param_converter.rb', line 25 def single_value @single_value ||= begin raise "Teach me how to handle #{key} = #{values}" if values.length != 1 # @type [String] values.fetch(0) end end |